Skip to content

Commit f62c546

Browse files
committed
Merge branch 'tb/save-keep-pack-during-geometric-repack'
When geometric repacking feature is in use together with the --pack-kept-objects option, we lost packs marked with .keep files. * tb/save-keep-pack-during-geometric-repack: repack: don't remove .keep packs with `--pack-kept-objects`
2 parents 2206040 + 197443e commit f62c546

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

builtin/repack.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,11 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
10891089
strbuf_addstr(&buf, pack_basename(p));
10901090
strbuf_strip_suffix(&buf, ".pack");
10911091

1092+
if ((p->pack_keep) ||
1093+
(string_list_has_string(&existing_kept_packs,
1094+
buf.buf)))
1095+
continue;
1096+
10921097
remove_redundant_pack(packdir, buf.buf);
10931098
}
10941099
strbuf_release(&buf);

t/t7700-repack.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,30 @@ test_expect_success '--write-midx -b packs non-kept objects' '
426426
)
427427
'
428428

429+
test_expect_success '--write-midx with --pack-kept-objects' '
430+
git init repo &&
431+
test_when_finished "rm -fr repo" &&
432+
(
433+
cd repo &&
434+
435+
test_commit one &&
436+
test_commit two &&
437+
438+
one="$(echo "one" | git pack-objects --revs $objdir/pack/pack)" &&
439+
two="$(echo "one..two" | git pack-objects --revs $objdir/pack/pack)" &&
440+
441+
keep="$objdir/pack/pack-$one.keep" &&
442+
touch "$keep" &&
443+
444+
git repack --write-midx --write-bitmap-index --geometric=2 -d \
445+
--pack-kept-objects &&
446+
447+
test_path_is_file $keep &&
448+
test_path_is_file $midx &&
449+
test_path_is_file $midx-$(midx_checksum $objdir).bitmap
450+
)
451+
'
452+
429453
test_expect_success TTY '--quiet disables progress' '
430454
test_terminal env GIT_PROGRESS_DELAY=0 \
431455
git -C midx repack -ad --quiet --write-midx 2>stderr &&

t/t7703-repack-geometric.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,12 @@ test_expect_success '--geometric ignores kept packs' '
176176
# be repacked, too.
177177
git repack --geometric 2 -d --pack-kept-objects &&
178178
179+
# After repacking, two packs remain: one new one (containing the
180+
# objects in both the .keep and non-kept pack), and the .keep
181+
# pack (since `--pack-kept-objects -d` does not actually delete
182+
# the kept pack).
179183
find $objdir/pack -name "*.pack" >after &&
180-
test_line_count = 1 after
184+
test_line_count = 2 after
181185
)
182186
'
183187

0 commit comments

Comments
 (0)