status: disable display of '#' comment prefix by default
[git/mingw.git] / t / t7060-wtstatus.sh
blob5ecafac99bacfb2f6f7527f2bf7989b52cc8d07b
1 #!/bin/sh
3 test_description='basic work tree status reporting'
5 . ./test-lib.sh
7 test_expect_success 'use status.displayCommentPrefix by default ' '
8 git config --global status.displayCommentPrefix true
11 test_expect_success setup '
12 git config --global advice.statusuoption false &&
13 test_commit A &&
14 test_commit B oneside added &&
15 git checkout A^0 &&
16 test_commit C oneside created
19 test_expect_success 'A/A conflict' '
20 git checkout B^0 &&
21 test_must_fail git merge C
24 test_expect_success 'Report path with conflict' '
25 git diff --cached --name-status >actual &&
26 echo "U oneside" >expect &&
27 test_cmp expect actual
30 test_expect_success 'Report new path with conflict' '
31 git diff --cached --name-status HEAD^ >actual &&
32 echo "U oneside" >expect &&
33 test_cmp expect actual
36 cat >expect <<EOF
37 # On branch side
38 # You have unmerged paths.
39 # (fix conflicts and run "git commit")
41 # Unmerged paths:
42 # (use "git add/rm <file>..." as appropriate to mark resolution)
44 # deleted by us: foo
46 no changes added to commit (use "git add" and/or "git commit -a")
47 EOF
49 test_expect_success 'M/D conflict does not segfault' '
50 mkdir mdconflict &&
52 cd mdconflict &&
53 git init &&
54 test_commit initial foo "" &&
55 test_commit modify foo foo &&
56 git checkout -b side HEAD^ &&
57 git rm foo &&
58 git commit -m delete &&
59 test_must_fail git merge master &&
60 test_must_fail git commit --dry-run >../actual &&
61 test_i18ncmp ../expect ../actual &&
62 git status >../actual &&
63 test_i18ncmp ../expect ../actual
67 test_expect_success 'rename & unmerged setup' '
68 git rm -f -r . &&
69 cat "$TEST_DIRECTORY/README" >ONE &&
70 git add ONE &&
71 test_tick &&
72 git commit -m "One commit with ONE" &&
74 echo Modified >TWO &&
75 cat ONE >>TWO &&
76 cat ONE >>THREE &&
77 git add TWO THREE &&
78 sha1=$(git rev-parse :ONE) &&
79 git rm --cached ONE &&
81 echo "100644 $sha1 1 ONE" &&
82 echo "100644 $sha1 2 ONE" &&
83 echo "100644 $sha1 3 ONE"
84 ) | git update-index --index-info &&
85 echo Further >>THREE
88 test_expect_success 'rename & unmerged status' '
89 git status -suno >actual &&
90 cat >expect <<-EOF &&
91 UU ONE
92 AM THREE
93 A TWO
94 EOF
95 test_cmp expect actual
98 test_expect_success 'git diff-index --cached shows 2 added + 1 unmerged' '
99 cat >expected <<-EOF &&
100 U ONE
101 A THREE
102 A TWO
104 git diff-index --cached --name-status HEAD >actual &&
105 test_cmp expected actual
108 test_expect_success 'git diff-index --cached -M shows 2 added + 1 unmerged' '
109 cat >expected <<-EOF &&
110 U ONE
111 A THREE
112 A TWO
114 git diff-index --cached --name-status HEAD >actual &&
115 test_cmp expected actual
118 test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' '
119 cat >expected <<-EOF &&
120 U ONE
121 C ONE THREE
122 C ONE TWO
124 git diff-index --cached -C --name-status HEAD |
125 sed "s/^C[0-9]*/C/g" >actual &&
126 test_cmp expected actual
130 test_expect_success 'status when conflicts with add and rm advice (deleted by them)' '
131 git reset --hard &&
132 git checkout master &&
133 test_commit init main.txt init &&
134 git checkout -b second_branch &&
135 git rm main.txt &&
136 git commit -m "main.txt deleted on second_branch" &&
137 test_commit second conflict.txt second &&
138 git checkout master &&
139 test_commit on_second main.txt on_second &&
140 test_commit master conflict.txt master &&
141 test_must_fail git merge second_branch &&
142 cat >expected <<-\EOF &&
143 # On branch master
144 # You have unmerged paths.
145 # (fix conflicts and run "git commit")
147 # Unmerged paths:
148 # (use "git add/rm <file>..." as appropriate to mark resolution)
150 # both added: conflict.txt
151 # deleted by them: main.txt
153 no changes added to commit (use "git add" and/or "git commit -a")
155 git status --untracked-files=no >actual &&
156 test_i18ncmp expected actual
160 test_expect_success 'prepare for conflicts' '
161 git reset --hard &&
162 git checkout -b conflict &&
163 test_commit one main.txt one &&
164 git branch conflict_second &&
165 git mv main.txt sub_master.txt &&
166 git commit -m "main.txt renamed in sub_master.txt" &&
167 git checkout conflict_second &&
168 git mv main.txt sub_second.txt &&
169 git commit -m "main.txt renamed in sub_second.txt"
173 test_expect_success 'status when conflicts with add and rm advice (both deleted)' '
174 test_must_fail git merge conflict &&
175 cat >expected <<-\EOF &&
176 # On branch conflict_second
177 # You have unmerged paths.
178 # (fix conflicts and run "git commit")
180 # Unmerged paths:
181 # (use "git add/rm <file>..." as appropriate to mark resolution)
183 # both deleted: main.txt
184 # added by them: sub_master.txt
185 # added by us: sub_second.txt
187 no changes added to commit (use "git add" and/or "git commit -a")
189 git status --untracked-files=no >actual &&
190 test_i18ncmp expected actual
194 test_expect_success 'status when conflicts with only rm advice (both deleted)' '
195 git reset --hard conflict_second &&
196 test_must_fail git merge conflict &&
197 git add sub_master.txt &&
198 git add sub_second.txt &&
199 cat >expected <<-\EOF &&
200 # On branch conflict_second
201 # You have unmerged paths.
202 # (fix conflicts and run "git commit")
204 # Changes to be committed:
206 # new file: sub_master.txt
208 # Unmerged paths:
209 # (use "git rm <file>..." to mark resolution)
211 # both deleted: main.txt
213 # Untracked files not listed (use -u option to show untracked files)
215 git status --untracked-files=no >actual &&
216 test_i18ncmp expected actual &&
217 git reset --hard &&
218 git checkout master
222 test_done