Re: What's cooking in git.git (Sep 2013, #01; Tue, 3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]