diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-02-12 10:08:51 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-02-12 10:08:52 -0800 |
| commit | 07c401d3922920c8edb2a1060806f06d9c4850b4 (patch) | |
| tree | eb0c55b895727d2b4b68ff8c45c3f1257d02c133 | |
| parent | aae91a86fb2a71ff89a71b63ccec3a947b26ca51 (diff) | |
| parent | 414c82300abf8d1f4c8ce7bacc68f3848bdb27f4 (diff) | |
| download | git-07c401d3922920c8edb2a1060806f06d9c4850b4.tar.xz | |
Merge branch 'ps/repack-keep-unreachable-in-unpacked-repo'
"git repack --keep-unreachable" to send unreachable objects to the
main pack "git repack -ad" produces did not work when there is no
existing packs, which has been corrected.
* ps/repack-keep-unreachable-in-unpacked-repo:
builtin/repack: fix `--keep-unreachable` when there are no packs
| -rw-r--r-- | builtin/repack.c | 5 | ||||
| -rwxr-xr-x | t/t7701-repack-unpack-unreachable.sh | 16 |
2 files changed, 20 insertions, 1 deletions
diff --git a/builtin/repack.c b/builtin/repack.c index e472586ed5..75e3752353 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -1377,9 +1377,12 @@ int cmd_repack(int argc, "--unpack-unreachable"); } else if (keep_unreachable) { strvec_push(&cmd.args, "--keep-unreachable"); - strvec_push(&cmd.args, "--pack-loose-unreachable"); } } + + if (keep_unreachable && delete_redundant && + !(pack_everything & PACK_CRUFT)) + strvec_push(&cmd.args, "--pack-loose-unreachable"); } else if (geometry.split_factor) { strvec_push(&cmd.args, "--stdin-packs"); strvec_push(&cmd.args, "--unpacked"); diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh index 5715f4d69a..5559d4ccb4 100755 --- a/t/t7701-repack-unpack-unreachable.sh +++ b/t/t7701-repack-unpack-unreachable.sh @@ -195,4 +195,20 @@ test_expect_success 'repack -k packs unreachable loose objects' ' git cat-file -p $sha1 ' +test_expect_success 'repack -k packs unreachable loose objects without existing packfiles' ' + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + + oid=$(echo would-be-deleted-loose | git hash-object -w --stdin) && + objpath=.git/objects/$(echo $sha1 | sed "s,..,&/,") && + test_path_is_file $objpath && + + git repack -ad --keep-unreachable && + test_path_is_missing $objpath && + git cat-file -p $oid + ) +' + test_done |
