git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: What's cooking in git.git (Sep 2013, #01; Tue, 3)
Date: Wed, 4 Sep 2013 05:01:53 -0400	[thread overview]
Message-ID: <20130904090153.GA22348@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqppspo6i7.fsf@gitster.dls.corp.google.com>

On Tue, Sep 03, 2013 at 04:00:32PM -0700, Junio C Hamano wrote:

> * jk/duplicate-objects-in-packs (2013-08-24) 6 commits
>  - default pack.indexDuplicates to false
>  - index-pack: optionally reject packs with duplicate objects
>  - test index-pack on packs with recoverable delta cycles
>  - add tests for indexing packs with delta cycles
>  - sha1-lookup: handle duplicate keys with GIT_USE_LOOKUP
>  - test-sha1: add a binary output mode
> 
>  A packfile that stores the same object more than once is broken and
>  will be rejected.
> 
>  Will merge to 'next'.

Hmph. I happened to be looking at the write_idx_file code a few minutes
ago, and noticed the results of commit 68be2fe (receive-pack,
fetch-pack: reject bogus pack that records objects twice, 2011-11-16).

Now I feel like a dunce for reimplementing the same thing a few lines
above (and the reason I did not catch it in my tests is that "index-pack
--strict" is not enabled by default).

We should probably drop the two top commits. We may want to keep the
test from the second-to-last, though, but change it to use "index-pack
--strict". Like this:

-- >8 --
Subject: t5308: check that index-pack --strict detects duplicate objects

Commit 68be2fe long ago taught index-pack to notice and
reject duplicate objects if --strict is given (which it is
for incoming packs, if transfer.fsckObjects is set).
However, it never tested the code, because we did not have
an easy way of generating such a bogus pack.

Now that we have test infrastructure to handle this, let's
confirm that it works.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t5308-pack-detect-duplicates.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/t/t5308-pack-detect-duplicates.sh b/t/t5308-pack-detect-duplicates.sh
index 04fe242..9c5a876 100755
--- a/t/t5308-pack-detect-duplicates.sh
+++ b/t/t5308-pack-detect-duplicates.sh
@@ -70,4 +70,11 @@ test_expect_success 'lookup in duplicated pack (GIT_USE_LOOKUP)' '
 	test_cmp expect actual
 '
 
+test_expect_success 'index-pack can reject packs with duplicates' '
+	clear_packs &&
+	create_pack dups.pack 2 &&
+	test_must_fail git index-pack --strict --stdin <dups.pack &&
+	test_expect_code 1 git cat-file -e $LO_SHA1
+'
+
 test_done
-- 
1.8.4.2.g87d4a77

  reply	other threads:[~2013-09-04  9:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-03 23:00 What's cooking in git.git (Sep 2013, #01; Tue, 3) Junio C Hamano
2013-09-04  9:01 ` Jeff King [this message]
2013-09-04 11:50 ` Matthieu Moy
2013-09-04 19:19   ` Junio C Hamano
2013-09-04 20:52     ` Jens Lehmann
2013-09-05  6:32       ` Matthieu Moy
2013-09-06  2:11 ` Jiang Xin
2013-09-06 16:28   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130904090153.GA22348@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).