]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7106-reset-unborn-branch.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t7106-reset-unborn-branch.sh
1 #!/bin/sh
2
3 test_description='git reset should work on unborn branch'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'setup' '
9 echo a >a &&
10 echo b >b
11 '
12
13 test_expect_success 'reset' '
14 git add a b &&
15 git reset &&
16
17 git ls-files >actual &&
18 test_must_be_empty actual
19 '
20
21 test_expect_success 'reset HEAD' '
22 rm .git/index &&
23 git add a b &&
24 test_must_fail git reset HEAD
25 '
26
27 test_expect_success 'reset $file' '
28 rm .git/index &&
29 git add a b &&
30 git reset a &&
31
32 echo b >expect &&
33 git ls-files >actual &&
34 test_cmp expect actual
35 '
36
37 test_expect_success 'reset -p' '
38 rm .git/index &&
39 git add a &&
40 echo y >yes &&
41 git reset -p <yes >output &&
42
43 git ls-files >actual &&
44 test_must_be_empty actual &&
45 test_grep "Unstage" output
46 '
47
48 test_expect_success 'reset --soft is a no-op' '
49 rm .git/index &&
50 git add a &&
51 git reset --soft &&
52
53 echo a >expect &&
54 git ls-files >actual &&
55 test_cmp expect actual
56 '
57
58 test_expect_success 'reset --hard' '
59 rm .git/index &&
60 git add a &&
61 test_when_finished "echo a >a" &&
62 git reset --hard &&
63
64 git ls-files >actual &&
65 test_must_be_empty actual &&
66 test_path_is_missing a
67 '
68
69 test_done