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