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.
12 Unless the directory already exists, in which case we clean up only what we
19 test_when_finished "rmdir foo/.git/objects.bak" &&
20 mkdir foo/.git/objects.bak/ &&
21 test_when_finished "mv foo/.git/objects.bak/* foo/.git/objects/" &&
22 mv foo/.git/objects/* foo/.git/objects.bak/
25 test_expect_success 'clone of non-existent source should fail' '
26 test_must_fail git clone foo bar
29 test_expect_success 'failed clone should not leave a directory' '
30 test_path_is_missing bar
33 test_expect_success 'create a repo to clone' '
37 test_expect_success 'create objects in repo for later corruption' '
38 test_commit -C foo file
41 # source repository given to git clone should be relative to the
42 # current path not to the target dir
43 test_expect_success 'clone of non-existent (relative to $PWD) source should fail' '
44 test_must_fail git clone ../foo baz
47 test_expect_success 'clone should work now that source exists' '
51 test_expect_success 'successful clone must leave the directory' '
55 test_expect_success 'failed clone --separate-git-dir should not leave any directories' '
57 test_must_fail git clone --separate-git-dir gitdir foo worktree &&
58 test_path_is_missing gitdir &&
59 test_path_is_missing worktree
62 test_expect_success 'failed clone into empty leaves directory (vanilla)' '
65 test_must_fail git clone foo empty &&
66 test_dir_is_empty empty
69 test_expect_success 'failed clone into empty leaves directory (bare)' '
72 test_must_fail git clone --bare foo empty &&
73 test_dir_is_empty empty
76 test_expect_success 'failed clone into empty leaves directory (separate)' '
77 mkdir -p empty-git empty-wt &&
79 test_must_fail git clone --separate-git-dir empty-git foo empty-wt &&
80 test_dir_is_empty empty-git &&
81 test_dir_is_empty empty-wt
84 test_expect_success 'failed clone into empty leaves directory (separate, git)' '
87 test_must_fail git clone --separate-git-dir empty-git foo no-wt &&
88 test_dir_is_empty empty-git &&
89 test_path_is_missing no-wt
92 test_expect_success 'failed clone into empty leaves directory (separate, wt)' '
95 test_must_fail git clone --separate-git-dir no-git foo empty-wt &&
96 test_path_is_missing no-git &&
97 test_dir_is_empty empty-wt