interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t7106-reset-unborn-branch.sh

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