t5308: check that index-pack --strict detects duplicate objects
authorJeff King <peff@peff.net>
Wed, 4 Sep 2013 09:01:53 +0000 (05:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Sep 2013 17:52:01 +0000 (10:52 -0700)
Commit 68be2fea (receive-pack, fetch-pack: reject bogus pack that
records objects twice, 2011-11-16) 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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5308-pack-detect-duplicates.sh
index 04fe242410ceaf5438734a3fba0cd5baa3eaa085..9c5a8766ab0af40382b83cf3340b13a32f7f0c8e 100755 (executable)
@@ -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