Skip to content

Commit 9898d85

Browse files
committed
Merge branch 'racy-dissociate'
This fixes a file-locking problem with `git clone --dissociate`. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 2a7953e + 1ff7b49 commit 9898d85

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

builtin/clone.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
10661066
transport_unlock_pack(transport);
10671067
transport_disconnect(transport);
10681068

1069-
if (option_dissociate)
1069+
if (option_dissociate) {
1070+
struct packed_git *p;
1071+
1072+
for (p = packed_git; p; p = p->next) {
1073+
close_pack_windows(p);
1074+
close_pack_index(p);
1075+
}
10701076
dissociate_from_references();
1077+
}
10711078

10721079
junk_mode = JUNK_LEAVE_REPO;
10731080
err = checkout();

t/t5700-clone-reference.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,26 @@ 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_success 'clone, dissociate from partial reference and repack' '
192+
rm -fr P Q R &&
193+
git init P &&
194+
(
195+
cd P &&
196+
test_commit one &&
197+
git repack &&
198+
test_commit two &&
199+
git repack
200+
) &&
201+
git clone --bare P Q &&
202+
(
203+
cd P &&
204+
git checkout -b second &&
205+
test_commit three &&
206+
git repack
207+
) &&
208+
git clone --bare --dissociate --reference=P Q R &&
209+
ls R/objects/pack/*.pack >packs.txt &&
210+
test_line_count = 1 packs.txt
211+
'
191212

192213
test_done

0 commit comments

Comments
 (0)