2013-01-15 09:47:50 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git reset should work on unborn branch'
|
|
|
|
. ./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-25 00:34:14 +04:00
|
|
|
|
|
|
|
>expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual
|
2013-01-15 09:47:50 +04: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-25 00:34:14 +04:00
|
|
|
|
|
|
|
echo b >expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual
|
2013-01-15 09:47:50 +04:00
|
|
|
'
|
|
|
|
|
2013-08-24 08:01:46 +04:00
|
|
|
test_expect_success PERL 'reset -p' '
|
2013-01-15 09:47:50 +04:00
|
|
|
rm .git/index &&
|
|
|
|
git add a &&
|
2013-08-25 00:34:14 +04:00
|
|
|
echo y >yes &&
|
2013-10-25 10:54:06 +04:00
|
|
|
git reset -p <yes >output &&
|
2013-08-25 00:34:14 +04:00
|
|
|
|
|
|
|
>expect &&
|
|
|
|
git ls-files >actual &&
|
2013-10-25 10:54:06 +04:00
|
|
|
test_cmp expect actual &&
|
|
|
|
test_i18ngrep "Unstage" output
|
2013-01-15 09:47:50 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset --soft is a no-op' '
|
|
|
|
rm .git/index &&
|
|
|
|
git add a &&
|
2013-08-25 00:34:14 +04:00
|
|
|
git reset --soft &&
|
|
|
|
|
|
|
|
echo a >expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual
|
2013-01-15 09:47:50 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset --hard' '
|
|
|
|
rm .git/index &&
|
|
|
|
git add a &&
|
2013-08-25 00:34:14 +04:00
|
|
|
test_when_finished "echo a >a" &&
|
2013-01-15 09:47:50 +04:00
|
|
|
git reset --hard &&
|
2013-08-25 00:34:14 +04:00
|
|
|
|
|
|
|
>expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual &&
|
2013-01-15 09:47:50 +04:00
|
|
|
test_path_is_missing a
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|