2006-02-17 21:33:28 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (C) 2006 Carl D. Worth <cworth@cworth.org>
|
|
|
|
#
|
|
|
|
|
2008-09-03 08:59:29 +00:00
|
|
|
test_description='test git clone to cleanup after failure
|
2006-02-17 21:33:28 +00:00
|
|
|
|
2008-09-03 08:59:29 +00:00
|
|
|
This test covers the fact that if git clone fails, it should remove
|
2006-02-17 21:33:28 +00:00
|
|
|
the directory it created, to avoid the user having to manually
|
|
|
|
remove the directory before attempting a clone again.'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2018-01-02 21:09:00 +00:00
|
|
|
test_expect_success 'clone of non-existent source should fail' '
|
|
|
|
test_must_fail git clone foo bar
|
|
|
|
'
|
2006-02-17 21:33:28 +00:00
|
|
|
|
2018-01-02 21:09:00 +00:00
|
|
|
test_expect_success 'failed clone should not leave a directory' '
|
|
|
|
test_path_is_missing bar
|
|
|
|
'
|
2006-02-17 21:33:28 +00:00
|
|
|
|
2018-01-02 21:09:00 +00:00
|
|
|
test_expect_success 'create a repo to clone' '
|
|
|
|
test_create_repo foo
|
|
|
|
'
|
2006-02-17 21:33:28 +00:00
|
|
|
|
2018-01-02 21:09:00 +00:00
|
|
|
test_expect_success 'create objects in repo for later corruption' '
|
|
|
|
test_commit -C foo file
|
|
|
|
'
|
2006-02-17 21:33:28 +00:00
|
|
|
|
2008-09-03 08:59:29 +00:00
|
|
|
# source repository given to git clone should be relative to the
|
2006-10-14 12:02:51 +00:00
|
|
|
# current path not to the target dir
|
2018-01-02 21:09:00 +00:00
|
|
|
test_expect_success 'clone of non-existent (relative to $PWD) source should fail' '
|
|
|
|
test_must_fail git clone ../foo baz
|
|
|
|
'
|
2006-10-14 12:02:51 +00:00
|
|
|
|
2018-01-02 21:09:00 +00:00
|
|
|
test_expect_success 'clone should work now that source exists' '
|
|
|
|
git clone foo bar
|
|
|
|
'
|
2006-02-17 21:33:28 +00:00
|
|
|
|
2018-01-02 21:09:00 +00:00
|
|
|
test_expect_success 'successful clone must leave the directory' '
|
|
|
|
test_path_is_dir bar
|
|
|
|
'
|
2013-01-05 20:17:04 +00:00
|
|
|
|
|
|
|
test_expect_success 'failed clone --separate-git-dir should not leave any directories' '
|
2018-01-02 21:09:00 +00:00
|
|
|
test_when_finished "rmdir foo/.git/objects.bak" &&
|
2013-01-05 20:17:04 +00:00
|
|
|
mkdir foo/.git/objects.bak/ &&
|
2018-01-02 21:09:00 +00:00
|
|
|
test_when_finished "mv foo/.git/objects.bak/* foo/.git/objects/" &&
|
2013-01-05 20:17:04 +00:00
|
|
|
mv foo/.git/objects/* foo/.git/objects.bak/ &&
|
|
|
|
test_must_fail git clone --separate-git-dir gitdir foo worktree &&
|
2018-01-02 21:09:00 +00:00
|
|
|
test_path_is_missing gitdir &&
|
|
|
|
test_path_is_missing worktree
|
2013-01-05 20:17:04 +00:00
|
|
|
'
|
2006-02-17 21:33:28 +00:00
|
|
|
|
|
|
|
test_done
|