]>
Commit | Line | Data |
---|---|---|
5508a616 CW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (C) 2006 Carl D. Worth <cworth@cworth.org> | |
4 | # | |
5 | ||
3604e7c5 | 6 | test_description='test git clone to cleanup after failure |
5508a616 | 7 | |
3604e7c5 | 8 | This test covers the fact that if git clone fails, it should remove |
5508a616 CW |
9 | the directory it created, to avoid the user having to manually |
10 | remove the directory before attempting a clone again.' | |
11 | ||
12 | . ./test-lib.sh | |
13 | ||
8486b84f JK |
14 | test_expect_success 'clone of non-existent source should fail' ' |
15 | test_must_fail git clone foo bar | |
16 | ' | |
5508a616 | 17 | |
8486b84f JK |
18 | test_expect_success 'failed clone should not leave a directory' ' |
19 | test_path_is_missing bar | |
20 | ' | |
5508a616 | 21 | |
8486b84f JK |
22 | test_expect_success 'create a repo to clone' ' |
23 | test_create_repo foo | |
24 | ' | |
5508a616 | 25 | |
8486b84f JK |
26 | test_expect_success 'create objects in repo for later corruption' ' |
27 | test_commit -C foo file | |
28 | ' | |
5508a616 | 29 | |
3604e7c5 | 30 | # source repository given to git clone should be relative to the |
ced78b39 | 31 | # current path not to the target dir |
8486b84f JK |
32 | test_expect_success 'clone of non-existent (relative to $PWD) source should fail' ' |
33 | test_must_fail git clone ../foo baz | |
34 | ' | |
ced78b39 | 35 | |
8486b84f JK |
36 | test_expect_success 'clone should work now that source exists' ' |
37 | git clone foo bar | |
38 | ' | |
5508a616 | 39 | |
8486b84f JK |
40 | test_expect_success 'successful clone must leave the directory' ' |
41 | test_path_is_dir bar | |
42 | ' | |
9be1980b JL |
43 | |
44 | test_expect_success 'failed clone --separate-git-dir should not leave any directories' ' | |
8486b84f | 45 | test_when_finished "rmdir foo/.git/objects.bak" && |
9be1980b | 46 | mkdir foo/.git/objects.bak/ && |
8486b84f | 47 | test_when_finished "mv foo/.git/objects.bak/* foo/.git/objects/" && |
9be1980b JL |
48 | mv foo/.git/objects/* foo/.git/objects.bak/ && |
49 | test_must_fail git clone --separate-git-dir gitdir foo worktree && | |
8486b84f JK |
50 | test_path_is_missing gitdir && |
51 | test_path_is_missing worktree | |
9be1980b | 52 | ' |
5508a616 CW |
53 | |
54 | test_done |