Skip to content

Commit f305016

Browse files
committed
Merge branch 'jk/disable-pack-reuse-when-broken' into maint
"pack-objects" can stream a slice of an existing packfile out when the pack bitmap can tell that the reachable objects are all needed in the output, without inspecting individual objects. This strategy however would not work well when "--local" and other options are in use, and need to be disabled. * jk/disable-pack-reuse-when-broken: t5310: fix "; do" style pack-objects: disable pack reuse for object-selection options
2 parents 70d19a4 + da5a1f8 commit f305016

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

builtin/pack-objects.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2717,7 +2717,11 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
27172717
*/
27182718
static int pack_options_allow_reuse(void)
27192719
{
2720-
return pack_to_stdout && allow_ofs_delta;
2720+
return pack_to_stdout &&
2721+
allow_ofs_delta &&
2722+
!ignore_packed_keep &&
2723+
(!local || !have_non_local_packs) &&
2724+
!incremental;
27212725
}
27222726

27232727
static int get_object_list_from_bitmap(struct rev_info *revs)

t/t5310-pack-bitmaps.sh

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ has_any () {
2020
}
2121

2222
test_expect_success 'setup repo with moderate-sized history' '
23-
for i in $(test_seq 1 10); do
23+
for i in $(test_seq 1 10)
24+
do
2425
test_commit $i
2526
done &&
2627
git checkout -b other HEAD~5 &&
27-
for i in $(test_seq 1 10); do
28+
for i in $(test_seq 1 10)
29+
do
2830
test_commit side-$i
2931
done &&
3032
git checkout master &&
@@ -104,7 +106,8 @@ test_expect_success 'clone from bitmapped repository' '
104106
'
105107

106108
test_expect_success 'setup further non-bitmapped commits' '
107-
for i in $(test_seq 1 10); do
109+
for i in $(test_seq 1 10)
110+
do
108111
test_commit further-$i
109112
done
110113
'
@@ -289,4 +292,43 @@ test_expect_success 'splitting packs does not generate bogus bitmaps' '
289292
git -C no-bitmaps.git fetch .. HEAD
290293
'
291294

295+
test_expect_success 'set up reusable pack' '
296+
rm -f .git/objects/pack/*.keep &&
297+
git repack -adb &&
298+
reusable_pack () {
299+
git for-each-ref --format="%(objectname)" |
300+
git pack-objects --delta-base-offset --revs --stdout "$@"
301+
}
302+
'
303+
304+
test_expect_success 'pack reuse respects --honor-pack-keep' '
305+
test_when_finished "rm -f .git/objects/pack/*.keep" &&
306+
for i in .git/objects/pack/*.pack
307+
do
308+
>${i%.pack}.keep
309+
done &&
310+
reusable_pack --honor-pack-keep >empty.pack &&
311+
git index-pack empty.pack &&
312+
>expect &&
313+
git show-index <empty.idx >actual &&
314+
test_cmp expect actual
315+
'
316+
317+
test_expect_success 'pack reuse respects --local' '
318+
mv .git/objects/pack/* alt.git/objects/pack/ &&
319+
test_when_finished "mv alt.git/objects/pack/* .git/objects/pack/" &&
320+
reusable_pack --local >empty.pack &&
321+
git index-pack empty.pack &&
322+
>expect &&
323+
git show-index <empty.idx >actual &&
324+
test_cmp expect actual
325+
'
326+
327+
test_expect_success 'pack reuse respects --incremental' '
328+
reusable_pack --incremental >empty.pack &&
329+
git index-pack empty.pack &&
330+
>expect &&
331+
git show-index <empty.idx >actual &&
332+
test_cmp expect actual
333+
'
292334
test_done

0 commit comments

Comments
 (0)