Skip to content

Commit 96a862b

Browse files
committed
Merge branch 'ps/repack-keep-unreachable-in-unpacked-repo' into next
"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
2 parents d83bc70 + 414c823 commit 96a862b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

builtin/repack.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,9 +1377,12 @@ int cmd_repack(int argc,
13771377
"--unpack-unreachable");
13781378
} else if (keep_unreachable) {
13791379
strvec_push(&cmd.args, "--keep-unreachable");
1380-
strvec_push(&cmd.args, "--pack-loose-unreachable");
13811380
}
13821381
}
1382+
1383+
if (keep_unreachable && delete_redundant &&
1384+
!(pack_everything & PACK_CRUFT))
1385+
strvec_push(&cmd.args, "--pack-loose-unreachable");
13831386
} else if (geometry.split_factor) {
13841387
strvec_push(&cmd.args, "--stdin-packs");
13851388
strvec_push(&cmd.args, "--unpacked");

t/t7701-repack-unpack-unreachable.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,20 @@ test_expect_success 'repack -k packs unreachable loose objects' '
195195
git cat-file -p $sha1
196196
'
197197

198+
test_expect_success 'repack -k packs unreachable loose objects without existing packfiles' '
199+
test_when_finished "rm -rf repo" &&
200+
git init repo &&
201+
(
202+
cd repo &&
203+
204+
oid=$(echo would-be-deleted-loose | git hash-object -w --stdin) &&
205+
objpath=.git/objects/$(echo $sha1 | sed "s,..,&/,") &&
206+
test_path_is_file $objpath &&
207+
208+
git repack -ad --keep-unreachable &&
209+
test_path_is_missing $objpath &&
210+
git cat-file -p $oid
211+
)
212+
'
213+
198214
test_done

0 commit comments

Comments
 (0)