3 # Copyright (C) 2006 Carl D. Worth <cworth@cworth.org>
6 test_description
='test git clone to cleanup after failure
8 This test covers the fact that if git clone fails, it should remove
9 the directory it created, to avoid the user having to manually
10 remove the directory before attempting a clone again.'
15 'clone of non-existent source should fail' \
16 'test_must_fail git clone foo bar'
19 'failed clone should not leave a directory' \
22 # Need a repo to clone
25 # clone doesn't like it if there is no HEAD. Is that a bug?
26 (cd foo
&& touch file && git add
file && git commit
-m 'add file' >/dev
/null
2>&1)
28 # source repository given to git clone should be relative to the
29 # current path not to the target dir
31 'clone of non-existent (relative to $PWD) source should fail' \
32 'test_must_fail git clone ../foo baz'
35 'clone should work now that source exists' \
39 'successful clone must leave the directory' \
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