summaryrefslogtreecommitdiffstats
path: root/t/t7106-reset-unborn-branch.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:47:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:47:53 +0000
commitc8bae7493d2f2910b57f13ded012e86bdcfb0532 (patch)
tree24e09d9f84dec336720cf393e156089ca2835791 /t/t7106-reset-unborn-branch.sh
parentInitial commit. (diff)
downloadgit-c8bae7493d2f2910b57f13ded012e86bdcfb0532.tar.xz
git-c8bae7493d2f2910b57f13ded012e86bdcfb0532.zip
Adding upstream version 1:2.39.2.upstream/1%2.39.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/t7106-reset-unborn-branch.sh')
-rwxr-xr-xt/t7106-reset-unborn-branch.sh67
1 files changed, 67 insertions, 0 deletions
diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh
new file mode 100755
index 0000000..ecb85c3
--- /dev/null
+++ b/t/t7106-reset-unborn-branch.sh
@@ -0,0 +1,67 @@
+#!/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 &&
+
+ git ls-files >actual &&
+ test_must_be_empty actual
+'
+
+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 &&
+
+ echo b >expect &&
+ git ls-files >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success PERL 'reset -p' '
+ rm .git/index &&
+ git add a &&
+ echo y >yes &&
+ git reset -p <yes >output &&
+
+ git ls-files >actual &&
+ test_must_be_empty actual &&
+ test_i18ngrep "Unstage" output
+'
+
+test_expect_success 'reset --soft is a no-op' '
+ rm .git/index &&
+ git add a &&
+ git reset --soft &&
+
+ echo a >expect &&
+ git ls-files >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'reset --hard' '
+ rm .git/index &&
+ git add a &&
+ test_when_finished "echo a >a" &&
+ git reset --hard &&
+
+ git ls-files >actual &&
+ test_must_be_empty actual &&
+ test_path_is_missing a
+'
+
+test_done