3 test_description
='basic work tree status reporting'
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 &&
14 test_commit B oneside added &&
16 test_commit C oneside created
19 test_expect_success
'A/A conflict' '
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
38 # You have unmerged paths.
39 # (fix conflicts and run "git commit")
42 # (use "git add/rm <file>..." as appropriate to mark resolution)
46 no changes added to commit (use "git add" and/or "git commit -a")
49 test_expect_success
'M/D conflict does not segfault' '
54 test_commit initial foo "" &&
55 test_commit modify foo foo &&
56 git checkout -b side HEAD^ &&
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' '
69 cat "$TEST_DIRECTORY/README" >ONE &&
72 git commit -m "One commit with ONE" &&
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 &&
88 test_expect_success
'rename & unmerged status' '
89 git status -suno >actual &&
95 test_cmp expect actual
98 test_expect_success
'git diff-index --cached shows 2 added + 1 unmerged' '
99 cat >expected <<-EOF &&
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 &&
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 &&
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)' '
132 git checkout master &&
133 test_commit init main.txt init &&
134 git checkout -b second_branch &&
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 &&
144 # You have unmerged paths.
145 # (fix conflicts and run "git commit")
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' '
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")
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
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 &&