diff --git a/builtin/repack.c b/builtin/repack.c index c4360382c1..7797972642 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -391,6 +391,13 @@ int cmd_repack(int argc, oidset_iter_init(&drop_oids, &iter); while ((oid = oidset_iter_next(&iter))) printf("%s\n", oid_to_hex(oid)); + + /* + * Only list the candidates to be dropped; skip + * the actual repack + */ + ret = 0; + goto cleanup; } } diff --git a/t/t7706-repack-drop-filtered.sh b/t/t7706-repack-drop-filtered.sh index cb36115834..a1c475e4ec 100755 --- a/t/t7706-repack-drop-filtered.sh +++ b/t/t7706-repack-drop-filtered.sh @@ -135,6 +135,25 @@ test_expect_success '--dry-run does not remove the filtered objects' ' git -C repo cat-file -e "$BIG" ' +test_expect_success '--dry-run leaves the pack directory untouched' ' + BIG=$(cat big_oid) && + packdir=repo/.git/objects/pack && + + for opt in "" -d + do + ls $packdir >before && + + git -C repo -c repack.writeBitmaps=false \ + repack --drop-filtered --filter=blob:limit=1k \ + --dry-run -a $opt >out && + + ls $packdir >after && + test_cmp before after && + test_grep "$BIG" out && + git -C repo cat-file -e "$BIG" || return 1 + done +' + test_expect_success '--drop-filtered removes the promisor blob locally' ' BIG=$(cat big_oid) && SMALL=$(cat small_oid) &&