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
This commit is contained in:
Junio C Hamano 2013-01-10 13:47:30 -08:00
Родитель d912b0e44f 9be1980bb9
Коммит 63d1cf6526
2 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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