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
This commit is contained in:
Junio C Hamano 2021-05-07 12:47:38 +09:00
Родитель e60e9cc20e 2ba582ba4c
Коммит 6e08cbdf38
4 изменённых файлов: 39 добавлений и 15 удалений

Просмотреть файл

@ -631,6 +631,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
traverse_commit_list_filtered(filter, revs,
show_commit, show_object,
&show_data, NULL);
revs->include_check = NULL;
revs->include_check_data = NULL;
}
return base;

Просмотреть файл

@ -227,17 +227,12 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
if (bitmap_git) {
traverse_bitmap_commit_list(bitmap_git, revs, mark_object_seen);
free_bitmap_index(bitmap_git);
return;
} else {
if (prepare_revision_walk(revs))
die("revision walk setup failed");
traverse_commit_list(revs, mark_commit, mark_object, &cp);
}
/*
* Set up the revision walk - this will move all commits
* from the pending list to the commit walking list.
*/
if (prepare_revision_walk(revs))
die("revision walk setup failed");
traverse_commit_list(revs, mark_commit, mark_object, &cp);
if (mark_recent) {
revs->ignore_missing_links = 1;
if (add_unseen_recent_objects_to_traversal(revs, mark_recent))

Просмотреть файл

@ -352,4 +352,20 @@ test_expect_success 'trivial prune with bitmaps enabled' '
test_must_fail git cat-file -e $blob
'
test_expect_success 'old reachable-from-recent retained with bitmaps' '
git repack -adb &&
to_drop=$(echo bitmap-from-recent-1 | git hash-object -w --stdin) &&
test-tool chmtime -86400 .git/objects/$(test_oid_to_path $to_drop) &&
to_save=$(echo bitmap-from-recent-2 | git hash-object -w --stdin) &&
test-tool chmtime -86400 .git/objects/$(test_oid_to_path $to_save) &&
tree=$(printf "100644 blob $to_save\tfile\n" | git mktree) &&
test-tool chmtime -86400 .git/objects/$(test_oid_to_path $tree) &&
commit=$(echo foo | git commit-tree $tree) &&
git prune --expire=12.hours.ago &&
git cat-file -e $commit &&
git cat-file -e $tree &&
git cat-file -e $to_save &&
test_must_fail git cat-file -e $to_drop
'
test_done

Просмотреть файл

@ -43,15 +43,25 @@ commit () {
}
maybe_repack () {
if test -n "$repack"; then
case "$title" in
loose)
: skip repack
;;
repack)
git repack -ad
fi
;;
bitmap)
git repack -adb
;;
*)
echo >&2 "unknown test type in maybe_repack"
return 1
;;
esac
}
for repack in '' true; do
title=${repack:+repack}
title=${title:-loose}
for title in loose repack bitmap
do
test_expect_success "make repo completely empty ($title)" '
rm -rf .git &&
git init