2013-01-15 06:47:50 +01: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-24 22:34:14 +02:00
|
|
|
|
|
|
|
>expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual
|
2013-01-15 06:47:50 +01: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 22:34:14 +02:00
|
|
|
|
|
|
|
echo b >expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual
|
2013-01-15 06:47:50 +01:00
|
|
|
'
|
|
|
|
|
2013-08-24 06:01:46 +02:00
|
|
|
test_expect_success PERL 'reset -p' '
|
2013-01-15 06:47:50 +01:00
|
|
|
rm .git/index &&
|
|
|
|
git add a &&
|
2013-08-24 22:34:14 +02:00
|
|
|
echo y >yes &&
|
2013-10-25 08:54:06 +02:00
|
|
|
git reset -p <yes >output &&
|
2013-08-24 22:34:14 +02:00
|
|
|
|
|
|
|
>expect &&
|
|
|
|
git ls-files >actual &&
|
2013-10-25 08:54:06 +02:00
|
|
|
test_cmp expect actual &&
|
|
|
|
test_i18ngrep "Unstage" output
|
2013-01-15 06:47:50 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset --soft is a no-op' '
|
|
|
|
rm .git/index &&
|
|
|
|
git add a &&
|
2013-08-24 22:34:14 +02:00
|
|
|
git reset --soft &&
|
|
|
|
|
|
|
|
echo a >expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual
|
2013-01-15 06:47:50 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'reset --hard' '
|
|
|
|
rm .git/index &&
|
|
|
|
git add a &&
|
2013-08-24 22:34:14 +02:00
|
|
|
test_when_finished "echo a >a" &&
|
2013-01-15 06:47:50 +01:00
|
|
|
git reset --hard &&
|
2013-08-24 22:34:14 +02:00
|
|
|
|
|
|
|
>expect &&
|
|
|
|
git ls-files >actual &&
|
|
|
|
test_cmp expect actual &&
|
2013-01-15 06:47:50 +01:00
|
|
|
test_path_is_missing a
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|