]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jl/interrupt-clone-remove-separate-git-dir' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2013 15:33:48 +0000 (07:33 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 14 Jan 2013 15:33:49 +0000 (07:33 -0800)
When "git clone --separate-git-dir=$over_there" is interrupted, it
failed to remove the real location of the $GIT_DIR it created.  This
was most visible when interrupting a submodule update.

* jl/interrupt-clone-remove-separate-git-dir:
  clone: support atomic operation with --separate-git-dir

builtin/clone.c
t/t5600-clone-fail-cleanup.sh

index ec2f75b4f3b9d9acfb8aa6b423f3b0fc7fbbafdf..8d23a62e8a1b875f1415f78a4c283f4cdefac011 100644 (file)
@@ -771,8 +771,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                die(_("could not create leading directories of '%s'"), git_dir);
 
        set_git_dir_init(git_dir, real_git_dir, 0);
-       if (real_git_dir)
+       if (real_git_dir) {
                git_dir = real_git_dir;
+               junk_git_dir = real_git_dir;
+       }
 
        if (0 <= option_verbosity) {
                if (option_bare)
index ee06d2864949de71b000402fda4378c9b483fe72..4435693bb2ca48d053003c87fccd8f8612d8b4a9 100755 (executable)
@@ -37,6 +37,16 @@ test_expect_success \
 
 test_expect_success \
     'successful clone must leave the directory' \
-    'cd bar'
+    'test -d bar'
+
+test_expect_success 'failed clone --separate-git-dir should not leave any directories' '
+       mkdir foo/.git/objects.bak/ &&
+       mv foo/.git/objects/* foo/.git/objects.bak/ &&
+       test_must_fail git clone --separate-git-dir gitdir foo worktree &&
+       test_must_fail test -e gitdir &&
+       test_must_fail test -e worktree &&
+       mv foo/.git/objects.bak/* foo/.git/objects/ &&
+       rmdir foo/.git/objects.bak
+'
 
 test_done