t5600: modernize style
[alt-git.git] / t / t5600-clone-fail-cleanup.sh
blob7b2a8052f893fad759294cfa54f55f3aed4cfaad
1 #!/bin/sh
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 . ./test-lib.sh
14 test_expect_success 'clone of non-existent source should fail' '
15 test_must_fail git clone foo bar
18 test_expect_success 'failed clone should not leave a directory' '
19 test_path_is_missing bar
22 test_expect_success 'create a repo to clone' '
23 test_create_repo foo
26 test_expect_success 'create objects in repo for later corruption' '
27 test_commit -C foo file
30 # source repository given to git clone should be relative to the
31 # current path not to the target dir
32 test_expect_success 'clone of non-existent (relative to $PWD) source should fail' '
33 test_must_fail git clone ../foo baz
36 test_expect_success 'clone should work now that source exists' '
37 git clone foo bar
40 test_expect_success 'successful clone must leave the directory' '
41 test_path_is_dir bar
44 test_expect_success 'failed clone --separate-git-dir should not leave any directories' '
45 test_when_finished "rmdir foo/.git/objects.bak" &&
46 mkdir foo/.git/objects.bak/ &&
47 test_when_finished "mv foo/.git/objects.bak/* foo/.git/objects/" &&
48 mv foo/.git/objects/* foo/.git/objects.bak/ &&
49 test_must_fail git clone --separate-git-dir gitdir foo worktree &&
50 test_path_is_missing gitdir &&
51 test_path_is_missing worktree
54 test_done