Skip to content

Commit 6e08cbd

Browse files
committed
Merge branch 'jk/prune-with-bitmap-fix'
When the reachability bitmap is in effect, the "do not lose recently created objects and those that are reachable from them" safety to protect us from races were disabled by mistake, which has been corrected. * jk/prune-with-bitmap-fix: prune: save reachable-from-recent objects with bitmaps pack-bitmap: clean up include_check after use
2 parents e60e9cc + 2ba582b commit 6e08cbd

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

pack-bitmap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
631631
traverse_commit_list_filtered(filter, revs,
632632
show_commit, show_object,
633633
&show_data, NULL);
634+
635+
revs->include_check = NULL;
636+
revs->include_check_data = NULL;
634637
}
635638

636639
return base;

reachable.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,12 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
227227
if (bitmap_git) {
228228
traverse_bitmap_commit_list(bitmap_git, revs, mark_object_seen);
229229
free_bitmap_index(bitmap_git);
230-
return;
230+
} else {
231+
if (prepare_revision_walk(revs))
232+
die("revision walk setup failed");
233+
traverse_commit_list(revs, mark_commit, mark_object, &cp);
231234
}
232235

233-
/*
234-
* Set up the revision walk - this will move all commits
235-
* from the pending list to the commit walking list.
236-
*/
237-
if (prepare_revision_walk(revs))
238-
die("revision walk setup failed");
239-
traverse_commit_list(revs, mark_commit, mark_object, &cp);
240-
241236
if (mark_recent) {
242237
revs->ignore_missing_links = 1;
243238
if (add_unseen_recent_objects_to_traversal(revs, mark_recent))

t/t5304-prune.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,4 +352,20 @@ test_expect_success 'trivial prune with bitmaps enabled' '
352352
test_must_fail git cat-file -e $blob
353353
'
354354

355+
test_expect_success 'old reachable-from-recent retained with bitmaps' '
356+
git repack -adb &&
357+
to_drop=$(echo bitmap-from-recent-1 | git hash-object -w --stdin) &&
358+
test-tool chmtime -86400 .git/objects/$(test_oid_to_path $to_drop) &&
359+
to_save=$(echo bitmap-from-recent-2 | git hash-object -w --stdin) &&
360+
test-tool chmtime -86400 .git/objects/$(test_oid_to_path $to_save) &&
361+
tree=$(printf "100644 blob $to_save\tfile\n" | git mktree) &&
362+
test-tool chmtime -86400 .git/objects/$(test_oid_to_path $tree) &&
363+
commit=$(echo foo | git commit-tree $tree) &&
364+
git prune --expire=12.hours.ago &&
365+
git cat-file -e $commit &&
366+
git cat-file -e $tree &&
367+
git cat-file -e $to_save &&
368+
test_must_fail git cat-file -e $to_drop
369+
'
370+
355371
test_done

t/t6501-freshen-objects.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,25 @@ commit () {
4343
}
4444

4545
maybe_repack () {
46-
if test -n "$repack"; then
46+
case "$title" in
47+
loose)
48+
: skip repack
49+
;;
50+
repack)
4751
git repack -ad
48-
fi
52+
;;
53+
bitmap)
54+
git repack -adb
55+
;;
56+
*)
57+
echo >&2 "unknown test type in maybe_repack"
58+
return 1
59+
;;
60+
esac
4961
}
5062

51-
for repack in '' true; do
52-
title=${repack:+repack}
53-
title=${title:-loose}
54-
63+
for title in loose repack bitmap
64+
do
5565
test_expect_success "make repo completely empty ($title)" '
5666
rm -rf .git &&
5767
git init

0 commit comments

Comments
 (0)