3 # Copyright (c) 2006 Junio C Hamano
6 test_description
='Various diff formatting options'
13 test_expect_success setup
'
15 GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
16 GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
17 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
21 for i in 1 2 3; do echo $i; done >file0 &&
22 for i in A B; do echo $i; done >dir/sub &&
24 git add file0 file2 dir/sub &&
25 git commit -m Initial &&
30 GIT_AUTHOR_DATE="2006-06-26 00:01:00 +0000" &&
31 GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" &&
32 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
34 for i in 4 5 6; do echo $i; done >>file0 &&
35 for i in C D; do echo $i; done >>dir/sub &&
37 git update-index --remove file0 file2 dir/sub &&
38 git commit -m "Second${LF}${LF}This is the second commit." &&
40 GIT_AUTHOR_DATE="2006-06-26 00:02:00 +0000" &&
41 GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" &&
42 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
44 for i in A B C; do echo $i; done >file1 &&
46 for i in E F; do echo $i; done >>dir/sub &&
47 git update-index dir/sub &&
48 git commit -m Third &&
50 GIT_AUTHOR_DATE="2006-06-26 00:03:00 +0000" &&
51 GIT_COMMITTER_DATE="2006-06-26 00:03:00 +0000" &&
52 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
55 for i in A B C; do echo $i; done >>file0 &&
56 for i in 1 2; do echo $i; done >>dir/sub &&
59 git update-index file0 dir/sub &&
62 GIT_AUTHOR_DATE="2006-06-26 00:04:00 +0000" &&
63 GIT_COMMITTER_DATE="2006-06-26 00:04:00 +0000" &&
64 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
66 git checkout master &&
67 git pull -s ours . side &&
69 GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" &&
70 GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" &&
71 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
73 for i in A B C; do echo $i; done >>file0 &&
74 for i in 1 2; do echo $i; done >>dir/sub &&
75 git update-index file0 dir/sub &&
78 cp dir/sub dir3/sub &&
79 test-tool chmtime +1 dir3/sub &&
81 git config log.showroot false &&
84 GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
85 GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
86 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
87 git checkout -b rearrange initial &&
88 for i in B A; do echo $i; done >dir/sub &&
90 git commit -m "Rearranged lines in dir/sub" &&
91 git checkout master &&
93 GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
94 GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
95 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
96 git checkout -b mode initial &&
97 git update-index --chmod=+x file0 &&
98 git commit -m "update mode" &&
99 git checkout -f master &&
101 # Same merge as master, but with parents reversed. Hide it in a
102 # pseudo-ref to avoid impacting tests with --all.
103 commit=$(echo reverse |
104 git commit-tree -p master^2 -p master^1 master^{tree}) &&
105 git update-ref REVERSE $commit &&
107 git config diff.renames false &&
114 * [master
] Merge branch
'side'
115 ! [rearrange
] Rearranged lines
in dir
/sub
118 + [rearrange
] Rearranged lines
in dir
/sub
119 - [master
] Merge branch
'side'
123 +*++ [initial
] Initial
126 V
=$
(git version |
sed -e 's/^git version //' -e 's/\./\\./g')
138 BUG
"unknown magic $magic" ;;
141 cmd
="$magic $cmd" magic
=
144 test=$
(echo "$label" |
sed -e 's|[/ ][/ ]*|_|g')
145 pfx
=$
(printf "%04d" $test_count)
146 expect
="$TEST_DIRECTORY/t4013/diff.$test"
147 actual
="$pfx-diff.$test"
149 test_expect_success
"git $cmd # magic is ${magic:-(not used)}" '
154 GIT_PRINT_SHA1_ELLIPSIS=yes git $cmd ;;
158 sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
159 -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
165 *format-patch* | *-stat*)
166 test_i18ncmp "$expect" "$actual";;
168 test_cmp "$expect" "$actual";;
172 # this is to help developing new tests.
173 cp "$actual" "$expect"
180 diff-tree
-r --abbrev initial
181 diff-tree
-r --abbrev=4 initial
182 diff-tree
--root initial
183 diff-tree
--root --abbrev initial
184 :noellipses diff-tree
--root --abbrev initial
185 diff-tree
--root -r initial
186 diff-tree
--root -r --abbrev initial
187 :noellipses diff-tree
--root -r --abbrev initial
188 diff-tree
--root -r --abbrev=4 initial
189 :noellipses diff-tree
--root -r --abbrev=4 initial
191 diff-tree
--root -p initial
192 diff-tree
--patch-with-stat initial
193 diff-tree
--root --patch-with-stat initial
194 diff-tree
--patch-with-raw initial
195 diff-tree
--root --patch-with-raw initial
197 diff-tree
--pretty initial
198 diff-tree
--pretty --root initial
199 diff-tree
--pretty -p initial
200 diff-tree
--pretty --stat initial
201 diff-tree
--pretty --summary initial
202 diff-tree
--pretty --stat --summary initial
203 diff-tree
--pretty --root -p initial
204 diff-tree
--pretty --root --stat initial
205 # improved by Timo's patch
206 diff-tree
--pretty --root --summary initial
207 # improved by Timo's patch
208 diff-tree
--pretty --root --summary -r initial
209 diff-tree
--pretty --root --stat --summary initial
210 diff-tree
--pretty --patch-with-stat initial
211 diff-tree
--pretty --root --patch-with-stat initial
212 diff-tree
--pretty --patch-with-raw initial
213 diff-tree
--pretty --root --patch-with-raw initial
215 diff-tree
--pretty=oneline initial
216 diff-tree
--pretty=oneline
--root initial
217 diff-tree
--pretty=oneline
-p initial
218 diff-tree
--pretty=oneline
--root -p initial
219 diff-tree
--pretty=oneline
--patch-with-stat initial
220 # improved by Timo's patch
221 diff-tree
--pretty=oneline
--root --patch-with-stat initial
222 diff-tree
--pretty=oneline
--patch-with-raw initial
223 diff-tree
--pretty=oneline
--root --patch-with-raw initial
225 diff-tree
--pretty side
226 diff-tree
--pretty -p side
227 diff-tree
--pretty --patch-with-stat side
229 diff-tree initial mode
230 diff-tree
--stat initial mode
231 diff-tree
--summary initial mode
235 diff-tree
-p -m master
237 diff-tree
-c --abbrev master
238 :noellipses diff-tree
-c --abbrev master
239 diff-tree
--cc master
240 # stat only should show the diffstat with the first parent
241 diff-tree
-c --stat master
242 diff-tree
--cc --stat master
243 diff-tree
-c --stat --summary master
244 diff-tree
--cc --stat --summary master
245 # stat summary should show the diffstat and summary with the first parent
246 diff-tree
-c --stat --summary side
247 diff-tree
--cc --stat --summary side
248 diff-tree
--cc --shortstat master
249 diff-tree
--cc --summary REVERSE
250 # improved by Timo's patch
251 diff-tree
--cc --patch-with-stat master
252 # improved by Timo's patch
253 diff-tree
--cc --patch-with-stat --summary master
255 diff-tree
--cc --patch-with-stat --summary side
261 log
--patch-with-stat master
262 log
--root --patch-with-stat master
263 log
--root --patch-with-stat --summary master
264 # improved by Timo's patch
265 log
--root -c --patch-with-stat --summary master
266 # improved by Timo's patch
267 log
--root --cc --patch-with-stat --summary master
268 log
-p --first-parent master
269 log
-m -p --first-parent master
274 log
-SF master
--max-count=0
275 log
-SF master
--max-count=1
276 log
-SF master
--max-count=2
279 log
-GF -p --pickaxe-all master
281 log
--decorate=full
--all
283 rev-list
--parents HEAD
284 rev-list
--children HEAD
287 :noellipses whatchanged master
288 whatchanged
-p master
289 whatchanged
--root master
290 :noellipses whatchanged
--root master
291 whatchanged
--root -p master
292 whatchanged
--patch-with-stat master
293 whatchanged
--root --patch-with-stat master
294 whatchanged
--root --patch-with-stat --summary master
295 # improved by Timo's patch
296 whatchanged
--root -c --patch-with-stat --summary master
297 # improved by Timo's patch
298 whatchanged
--root --cc --patch-with-stat --summary master
299 whatchanged
-SF master
300 :noellipses whatchanged
-SF master
301 whatchanged
-SF -p master
303 log
--patch-with-stat master
-- dir
/
304 whatchanged
--patch-with-stat master
-- dir
/
305 log
--patch-with-stat --summary master
-- dir
/
306 whatchanged
--patch-with-stat --summary master
-- dir
/
314 show
--first-parent master
316 show
--stat --summary side
317 show
--patch-with-stat side
318 show
--patch-with-raw side
319 :noellipses show
--patch-with-raw side
320 show
--patch-with-stat --summary side
322 format-patch
--stdout initial..side
323 format-patch
--stdout initial..master^
324 format-patch
--stdout initial..master
325 format-patch
--stdout --no-numbered initial..master
326 format-patch
--stdout --numbered initial..master
327 format-patch
--attach --stdout initial..side
328 format-patch
--attach --stdout --suffix=.
diff initial..side
329 format-patch
--attach --stdout initial..master^
330 format-patch
--attach --stdout initial..master
331 format-patch
--inline --stdout initial..side
332 format-patch
--inline --stdout initial..master^
333 format-patch
--inline --stdout --numbered-files initial..master
334 format-patch
--inline --stdout initial..master
335 format-patch
--inline --stdout --subject-prefix=TESTCASE initial..master
336 config format.subjectprefix DIFFERENT_PREFIX
337 format-patch
--inline --stdout initial..master^^
338 format-patch
--stdout --cover-letter -n initial..master^
340 diff --abbrev initial..side
341 diff -U initial..side
342 diff -U1 initial..side
343 diff -r initial..side
344 diff --stat initial..side
345 diff -r --stat initial..side
347 diff --patch-with-stat initial..side
348 diff --patch-with-raw initial..side
349 :noellipses
diff --patch-with-raw initial..side
350 diff --patch-with-stat -r initial..side
351 diff --patch-with-raw -r initial..side
352 :noellipses
diff --patch-with-raw -r initial..side
353 diff --name-status dir2 dir
354 diff --no-index --name-status dir2 dir
355 diff --no-index --name-status -- dir2 dir
356 diff --no-index dir dir3
357 diff master master^ side
358 # Can't use spaces...
359 diff --line-prefix=abc master master^ side
360 diff --dirstat master~
1 master~
2
361 diff --dirstat initial rearrange
362 diff --dirstat-by-file initial rearrange
363 diff --dirstat --cc master~
1 master
364 # No-index --abbrev and --no-abbrev
366 :noellipses
diff --raw initial
367 diff --raw --abbrev=4 initial
368 :noellipses
diff --raw --abbrev=4 initial
369 diff --raw --no-abbrev initial
370 diff --no-index --raw dir2 dir
371 :noellipses
diff --no-index --raw dir2 dir
372 diff --no-index --raw --abbrev=4 dir2 dir
373 :noellipses
diff --no-index --raw --abbrev=4 dir2 dir
374 diff --no-index --raw --no-abbrev dir2 dir
376 diff-tree
--pretty --root --stat --compact-summary initial
377 diff-tree
--pretty -R --root --stat --compact-summary initial
378 diff-tree
--stat --compact-summary initial mode
379 diff-tree
-R --stat --compact-summary initial mode
382 test_expect_success
'log -S requires an argument' '
383 test_must_fail git log -S
386 test_expect_success
'diff --cached on unborn branch' '
387 echo ref: refs/heads/unborn >.git/HEAD &&
388 git diff --cached >result &&
389 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached" result
392 test_expect_success
'diff --cached -- file on unborn branch' '
393 git diff --cached -- file0 >result &&
394 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result
396 test_expect_success
'diff --line-prefix with spaces' '
397 git diff --line-prefix="| | | " --cached -- file0 >result &&
398 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" result
401 test_expect_success
'diff-tree --stdin with log formatting' '
402 cat >expect <<-\EOF &&
407 git rev-list master | git diff-tree --stdin --format=%s -s >actual &&
408 test_cmp expect actual