Skip to content

Commit 786b150

Browse files
dschogitster
authored andcommitted
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 hurt, either, though. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38849a8 commit 786b150

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
@@ -995,8 +995,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
995995
transport_unlock_pack(transport);
996996
transport_disconnect(transport);
997997

998-
if (option_dissociate)
998+
if (option_dissociate) {
999+
close_all_packs();
9991000
dissociate_from_references();
1001+
}
10001002

10011003
junk_mode = JUNK_LEAVE_REPO;
10021004
err = checkout();

t/t5700-clone-reference.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ test_expect_success 'clone and dissociate from reference' '
214214
test_must_fail git -C R fsck &&
215215
git -C S fsck
216216
'
217-
test_expect_failure MINGW 'clone, dissociate from partial reference and repack' '
217+
test_expect_success 'clone, dissociate from partial reference and repack' '
218218
rm -fr P Q R &&
219219
git init P &&
220220
(

0 commit comments

Comments
 (0)