Skip to content

Commit aebcf70

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 805e2c2 + a797af4 commit aebcf70

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
@@ -999,8 +999,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
999999
transport_unlock_pack(transport);
10001000
transport_disconnect(transport);
10011001

1002-
if (option_dissociate)
1002+
if (option_dissociate) {
1003+
struct packed_git *p;
1004+
1005+
for (p = packed_git; p; p = p->next) {
1006+
close_pack_windows(p);
1007+
close_pack_index(p);
1008+
}
10031009
dissociate_from_references();
1010+
}
10041011

10051012
junk_mode = JUNK_LEAVE_REPO;
10061013
err = checkout();

t/t5700-clone-reference.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,26 @@ 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_success 'clone, dissociate from partial reference and repack' '
218+
rm -fr P Q R &&
219+
git init P &&
220+
(
221+
cd P &&
222+
test_commit one &&
223+
git repack &&
224+
test_commit two &&
225+
git repack
226+
) &&
227+
git clone --bare P Q &&
228+
(
229+
cd P &&
230+
git checkout -b second &&
231+
test_commit three &&
232+
git repack
233+
) &&
234+
git clone --bare --dissociate --reference=P Q R &&
235+
ls R/objects/pack/*.pack >packs.txt &&
236+
test_line_count = 1 packs.txt
237+
'
217238

218239
test_done

0 commit comments

Comments
 (0)