]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7060-wtstatus.sh
Merge branch 'ab/i18n-fixup' into maint
[thirdparty/git.git] / t / t7060-wtstatus.sh
1 #!/bin/sh
2
3 test_description='basic work tree status reporting'
4
5 . ./test-lib.sh
6
7 test_expect_success setup '
8 test_commit A &&
9 test_commit B oneside added &&
10 git checkout A^0 &&
11 test_commit C oneside created
12 '
13
14 test_expect_success 'A/A conflict' '
15 git checkout B^0 &&
16 test_must_fail git merge C
17 '
18
19 test_expect_success 'Report path with conflict' '
20 git diff --cached --name-status >actual &&
21 echo "U oneside" >expect &&
22 test_cmp expect actual
23 '
24
25 test_expect_success 'Report new path with conflict' '
26 git diff --cached --name-status HEAD^ >actual &&
27 echo "U oneside" >expect &&
28 test_cmp expect actual
29 '
30
31 cat >expect <<EOF
32 # On branch side
33 # Unmerged paths:
34 # (use "git add/rm <file>..." as appropriate to mark resolution)
35 #
36 # deleted by us: foo
37 #
38 no changes added to commit (use "git add" and/or "git commit -a")
39 EOF
40
41 test_expect_success 'M/D conflict does not segfault' '
42 mkdir mdconflict &&
43 (
44 cd mdconflict &&
45 git init &&
46 test_commit initial foo "" &&
47 test_commit modify foo foo &&
48 git checkout -b side HEAD^ &&
49 git rm foo &&
50 git commit -m delete &&
51 test_must_fail git merge master &&
52 test_must_fail git commit --dry-run >../actual &&
53 test_i18ncmp ../expect ../actual &&
54 git status >../actual &&
55 test_i18ncmp ../expect ../actual
56 )
57 '
58
59 test_expect_success 'rename & unmerged setup' '
60 git rm -f -r . &&
61 cat "$TEST_DIRECTORY/README" >ONE &&
62 git add ONE &&
63 test_tick &&
64 git commit -m "One commit with ONE" &&
65
66 echo Modified >TWO &&
67 cat ONE >>TWO &&
68 cat ONE >>THREE &&
69 git add TWO THREE &&
70 sha1=$(git rev-parse :ONE) &&
71 git rm --cached ONE &&
72 (
73 echo "100644 $sha1 1 ONE" &&
74 echo "100644 $sha1 2 ONE" &&
75 echo "100644 $sha1 3 ONE"
76 ) | git update-index --index-info &&
77 echo Further >>THREE
78 '
79
80 test_expect_success 'rename & unmerged status' '
81 git status -suno >actual &&
82 cat >expect <<-EOF &&
83 UU ONE
84 AM THREE
85 A TWO
86 EOF
87 test_cmp expect actual
88 '
89
90 test_expect_success 'git diff-index --cached shows 2 added + 1 unmerged' '
91 cat >expected <<-EOF &&
92 U ONE
93 A THREE
94 A TWO
95 EOF
96 git diff-index --cached --name-status HEAD >actual &&
97 test_cmp expected actual
98 '
99
100 test_expect_success 'git diff-index --cached -M shows 2 added + 1 unmerged' '
101 cat >expected <<-EOF &&
102 U ONE
103 A THREE
104 A TWO
105 EOF
106 git diff-index --cached --name-status HEAD >actual &&
107 test_cmp expected actual
108 '
109
110 test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' '
111 cat >expected <<-EOF &&
112 U ONE
113 C ONE THREE
114 C ONE TWO
115 EOF
116 git diff-index --cached -C --name-status HEAD |
117 sed "s/^C[0-9]*/C/g" >actual &&
118 test_cmp expected actual
119 '
120
121 test_done