Skip to content

Commit b4dc11b

Browse files
committed
clone --dissociate: avoid locking pack files
When `git clone` is asked to dissociate the repository from the reference repository whose objects were used, it is quite possible that the pack files need to be repacked. In that case, the pack files need to be deleted that were originally hard-links to the reference repository's pack files. On platforms where a file cannot be deleted if another process still holds a handle on it, we therefore need to take pains to release all pack files and indexes before dissociating. This fixes #446 The test case to demonstrate the breakage technically does not need to be run on Linux or MacOSX. It won't hurth, either, though. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 02f6850 commit b4dc11b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

builtin/clone.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
10641064
transport_unlock_pack(transport);
10651065
transport_disconnect(transport);
10661066

1067-
if (option_dissociate)
1067+
if (option_dissociate) {
1068+
close_all_packs();
10681069
dissociate_from_references();
1070+
}
10691071

10701072
junk_mode = JUNK_LEAVE_REPO;
10711073
err = checkout();

t/t5700-clone-reference.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ test_expect_success 'clone and dissociate from reference' '
188188
test_must_fail git -C R fsck &&
189189
git -C S fsck
190190
'
191-
test_expect_failure MINGW 'clone, dissociate from partial reference and repack' '
191+
test_expect_success 'clone, dissociate from partial reference and repack' '
192192
rm -fr P Q R &&
193193
git init P &&
194194
(

0 commit comments

Comments
 (0)