2013-01-15 05:47:50 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git reset should work on unborn branch'
|
2023-02-06 23:07:40 +00:00
|
|
|
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2013-01-15 05:47:50 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
echo a >a &&
|
|
|
|
echo b >b
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset' '
|
|
|
|
git add a b &&
|
|
|
|
git reset &&
|
2013-08-24 20:34:14 +00:00
|
|
|
|
|
|
|
git ls-files >actual &&
|
2018-07-27 17:48:11 +00:00
|
|
|
test_must_be_empty actual
|
2013-01-15 05:47:50 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset HEAD' '
|
|
|
|
rm .git/index &&
|
|
|
|
git add a b &&
|
|
|
|
test_must_fail git reset HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset $file' '
|
|
|
|
rm .git/index &&
|
|
|
|
git add a b &&
|
|
|
|
git reset a &&
|
2013-08-24 20:34:14 +00:00
|
|
|
|
|
|
|
echo b >expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual
|
2013-01-15 05:47:50 +00:00
|
|
|
'
|
|
|
|
|
2013-08-24 04:01:46 +00:00
|
|
|
test_expect_success PERL 'reset -p' '
|
2013-01-15 05:47:50 +00:00
|
|
|
rm .git/index &&
|
|
|
|
git add a &&
|
2013-08-24 20:34:14 +00:00
|
|
|
echo y >yes &&
|
2013-10-25 06:54:06 +00:00
|
|
|
git reset -p <yes >output &&
|
2013-08-24 20:34:14 +00:00
|
|
|
|
|
|
|
git ls-files >actual &&
|
2018-07-27 17:48:11 +00:00
|
|
|
test_must_be_empty actual &&
|
2013-10-25 06:54:06 +00:00
|
|
|
test_i18ngrep "Unstage" output
|
2013-01-15 05:47:50 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset --soft is a no-op' '
|
|
|
|
rm .git/index &&
|
|
|
|
git add a &&
|
2013-08-24 20:34:14 +00:00
|
|
|
git reset --soft &&
|
|
|
|
|
|
|
|
echo a >expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual
|
2013-01-15 05:47:50 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset --hard' '
|
|
|
|
rm .git/index &&
|
|
|
|
git add a &&
|
2013-08-24 20:34:14 +00:00
|
|
|
test_when_finished "echo a >a" &&
|
2013-01-15 05:47:50 +00:00
|
|
|
git reset --hard &&
|
2013-08-24 20:34:14 +00:00
|
|
|
|
|
|
|
git ls-files >actual &&
|
2018-07-27 17:48:11 +00:00
|
|
|
test_must_be_empty actual &&
|
2013-01-15 05:47:50 +00:00
|
|
|
test_path_is_missing a
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|