summaryrefslogtreecommitdiffstats
path: root/t/t7106-reset-unborn-branch.sh
blob: d20e5709f91cd7b1a0107bf4ee1df6809001bd30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh

test_description='git reset should work on unborn branch'

TEST_PASSES_SANITIZE_LEAK=true
. ./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_grep "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