]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/index-pack-dupfix' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 17 Mar 2020 22:02:21 +0000 (15:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Mar 2020 22:02:22 +0000 (15:02 -0700)
The index-pack code now diagnoses a bad input packstream that
records the same object twice when it is used as delta base; the
code used to declare a software bug when encountering such an
input, but it is an input error.

* jk/index-pack-dupfix:
  index-pack: downgrade twice-resolved REF_DELTA to die()

builtin/index-pack.c
t/t5309-pack-delta-cycles.sh

index 60a5591039abbdb9e0050bfda53123c577b41864..41a7c11c8ef79771b2ad0f9f544471e626138941 100644 (file)
@@ -1003,7 +1003,9 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,
 
                if (!compare_and_swap_type(&child->real_type, OBJ_REF_DELTA,
                                           base->obj->real_type))
-                       BUG("child->real_type != OBJ_REF_DELTA");
+                       die("REF_DELTA at offset %"PRIuMAX" already resolved (duplicate base %s?)",
+                           (uintmax_t)child->idx.offset,
+                           oid_to_hex(&base->obj->idx.oid));
 
                resolve_delta(child, base, result);
                if (base->ref_first == base->ref_last && base->ofs_last == -1)
index 491556dad9792619974851ef255198c5d247af2f..6c209ad45cf5509f46ba977ef46b717dda86f504 100755 (executable)
@@ -62,13 +62,13 @@ test_expect_success 'index-pack detects REF_DELTA cycles' '
        test_must_fail git index-pack --fix-thin --stdin <cycle.pack
 '
 
-test_expect_failure 'failover to an object in another pack' '
+test_expect_success 'failover to an object in another pack' '
        clear_packs &&
        git index-pack --stdin <ab.pack &&
-       git index-pack --stdin --fix-thin <cycle.pack
+       test_must_fail git index-pack --stdin --fix-thin <cycle.pack
 '
 
-test_expect_failure 'failover to a duplicate object in the same pack' '
+test_expect_success 'failover to a duplicate object in the same pack' '
        clear_packs &&
        {
                pack_header 3 &&
@@ -77,7 +77,7 @@ test_expect_failure 'failover to a duplicate object in the same pack' '
                pack_obj $A
        } >recoverable.pack &&
        pack_trailer recoverable.pack &&
-       git index-pack --fix-thin --stdin <recoverable.pack
+       test_must_fail git index-pack --fix-thin --stdin <recoverable.pack
 '
 
 test_done