Skip to content

Commit 63d1cf6

Browse files
committed
Merge branch 'jl/interrupt-clone-remove-separate-git-dir'
When "git clone --separate-git-dir" is interrupted, we failed to remove the real location we created the repository. * jl/interrupt-clone-remove-separate-git-dir: clone: support atomic operation with --separate-git-dir
2 parents d912b0e + 9be1980 commit 63d1cf6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

builtin/clone.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
771771
die(_("could not create leading directories of '%s'"), git_dir);
772772

773773
set_git_dir_init(git_dir, real_git_dir, 0);
774-
if (real_git_dir)
774+
if (real_git_dir) {
775775
git_dir = real_git_dir;
776+
junk_git_dir = real_git_dir;
777+
}
776778

777779
if (0 <= option_verbosity) {
778780
if (option_bare)

t/t5600-clone-fail-cleanup.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ test_expect_success \
3737

3838
test_expect_success \
3939
'successful clone must leave the directory' \
40-
'cd bar'
40+
'test -d bar'
41+
42+
test_expect_success 'failed clone --separate-git-dir should not leave any directories' '
43+
mkdir foo/.git/objects.bak/ &&
44+
mv foo/.git/objects/* foo/.git/objects.bak/ &&
45+
test_must_fail git clone --separate-git-dir gitdir foo worktree &&
46+
test_must_fail test -e gitdir &&
47+
test_must_fail test -e worktree &&
48+
mv foo/.git/objects.bak/* foo/.git/objects/ &&
49+
rmdir foo/.git/objects.bak
50+
'
4151

4252
test_done

0 commit comments

Comments
 (0)