Skip to content

Commit 7e84f46

Browse files
committed
Merge branch 'jk/index-pack-dupfix' into maint
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()
2 parents fa24bbe + a217810 commit 7e84f46

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

builtin/index-pack.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,9 @@ static struct base_data *find_unresolved_deltas_1(struct base_data *base,
10031003

10041004
if (!compare_and_swap_type(&child->real_type, OBJ_REF_DELTA,
10051005
base->obj->real_type))
1006-
BUG("child->real_type != OBJ_REF_DELTA");
1006+
die("REF_DELTA at offset %"PRIuMAX" already resolved (duplicate base %s?)",
1007+
(uintmax_t)child->idx.offset,
1008+
oid_to_hex(&base->obj->idx.oid));
10071009

10081010
resolve_delta(child, base, result);
10091011
if (base->ref_first == base->ref_last && base->ofs_last == -1)

t/t5309-pack-delta-cycles.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ test_expect_success 'index-pack detects REF_DELTA cycles' '
6262
test_must_fail git index-pack --fix-thin --stdin <cycle.pack
6363
'
6464

65-
test_expect_failure 'failover to an object in another pack' '
65+
test_expect_success 'failover to an object in another pack' '
6666
clear_packs &&
6767
git index-pack --stdin <ab.pack &&
68-
git index-pack --stdin --fix-thin <cycle.pack
68+
test_must_fail git index-pack --stdin --fix-thin <cycle.pack
6969
'
7070

71-
test_expect_failure 'failover to a duplicate object in the same pack' '
71+
test_expect_success 'failover to a duplicate object in the same pack' '
7272
clear_packs &&
7373
{
7474
pack_header 3 &&
@@ -77,7 +77,7 @@ test_expect_failure 'failover to a duplicate object in the same pack' '
7777
pack_obj $A
7878
} >recoverable.pack &&
7979
pack_trailer recoverable.pack &&
80-
git index-pack --fix-thin --stdin <recoverable.pack
80+
test_must_fail git index-pack --fix-thin --stdin <recoverable.pack
8181
'
8282

8383
test_done

0 commit comments

Comments
 (0)