blob: 3f60f7d96ce1998cd977751158c09cadfd926d15 [file] [log] [blame]
Junio C Hamano3c2f75b2006-06-26 13:46:52 -07001#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
6test_description='Various diff formatting options'
7
8. ./test-lib.sh
9
Junio C Hamano3c2f75b2006-06-26 13:46:52 -070010test_expect_success setup '
11
12 GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
13 GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
14 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
15
16 mkdir dir &&
Johannes Schindelin3cb56732007-07-03 16:01:06 +010017 mkdir dir2 &&
Junio C Hamano3c2f75b2006-06-26 13:46:52 -070018 for i in 1 2 3; do echo $i; done >file0 &&
19 for i in A B; do echo $i; done >dir/sub &&
20 cat file0 >file2 &&
21 git add file0 file2 dir/sub &&
22 git commit -m Initial &&
23
24 git branch initial &&
25 git branch side &&
26
27 GIT_AUTHOR_DATE="2006-06-26 00:01:00 +0000" &&
28 GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" &&
29 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
30
31 for i in 4 5 6; do echo $i; done >>file0 &&
32 for i in C D; do echo $i; done >>dir/sub &&
33 rm -f file2 &&
34 git update-index --remove file0 file2 dir/sub &&
Junio C Hamanoa40d3842006-07-13 19:51:12 -070035 git commit -m "Second${LF}${LF}This is the second commit." &&
Junio C Hamano3c2f75b2006-06-26 13:46:52 -070036
37 GIT_AUTHOR_DATE="2006-06-26 00:02:00 +0000" &&
38 GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" &&
39 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
40
41 for i in A B C; do echo $i; done >file1 &&
42 git add file1 &&
43 for i in E F; do echo $i; done >>dir/sub &&
44 git update-index dir/sub &&
45 git commit -m Third &&
46
47 GIT_AUTHOR_DATE="2006-06-26 00:03:00 +0000" &&
48 GIT_COMMITTER_DATE="2006-06-26 00:03:00 +0000" &&
49 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
50
51 git checkout side &&
52 for i in A B C; do echo $i; done >>file0 &&
53 for i in 1 2; do echo $i; done >>dir/sub &&
54 cat dir/sub >file3 &&
55 git add file3 &&
56 git update-index file0 dir/sub &&
57 git commit -m Side &&
58
59 GIT_AUTHOR_DATE="2006-06-26 00:04:00 +0000" &&
60 GIT_COMMITTER_DATE="2006-06-26 00:04:00 +0000" &&
61 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
62
63 git checkout master &&
64 git pull -s ours . side &&
65
66 GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" &&
67 GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" &&
68 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
69
70 for i in A B C; do echo $i; done >>file0 &&
71 for i in 1 2; do echo $i; done >>dir/sub &&
72 git update-index file0 dir/sub &&
73
Michael Spangd61027b2009-02-18 01:48:06 -050074 mkdir dir3 &&
75 cp dir/sub dir3/sub &&
Nguyễn Thái Ngọc Duy0e496492018-03-24 08:44:31 +010076 test-tool chmtime +1 dir3/sub &&
Michael Spangd61027b2009-02-18 01:48:06 -050077
Tom Princee0d10e12007-01-28 16:16:53 -080078 git config log.showroot false &&
Eric Wong8ff99e72006-07-11 12:01:54 -070079 git commit --amend &&
Johan Herland204f01a2011-04-11 00:48:50 +020080
81 GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
82 GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
83 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
84 git checkout -b rearrange initial &&
85 for i in B A; do echo $i; done >dir/sub &&
86 git add dir/sub &&
87 git commit -m "Rearranged lines in dir/sub" &&
88 git checkout master &&
89
Stefan Beller58aaced2017-09-27 15:51:26 -070090 GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
91 GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
92 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
93 git checkout -b mode initial &&
94 git update-index --chmod=+x file0 &&
95 git commit -m "update mode" &&
96 git checkout -f master &&
97
Taylor Blau5778b222020-04-20 18:13:15 -060098 GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
99 GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
100 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
101 git checkout -b note initial &&
102 git update-index --chmod=+x file2 &&
103 git commit -m "update mode (file2)" &&
104 git notes add -m "note" &&
105 git checkout -f master &&
106
Jeff King04b19fc2019-01-24 07:35:40 -0500107 # Same merge as master, but with parents reversed. Hide it in a
108 # pseudo-ref to avoid impacting tests with --all.
109 commit=$(echo reverse |
110 git commit-tree -p master^2 -p master^1 master^{tree}) &&
111 git update-ref REVERSE $commit &&
112
Matthieu Moy5404c112016-02-25 09:59:21 +0100113 git config diff.renames false &&
114
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700115 git show-branch
116'
117
118: <<\EOF
119! [initial] Initial
120 * [master] Merge branch 'side'
Johan Herland204f01a2011-04-11 00:48:50 +0200121 ! [rearrange] Rearranged lines in dir/sub
122 ! [side] Side
123----
124 + [rearrange] Rearranged lines in dir/sub
125 - [master] Merge branch 'side'
126 * + [side] Side
127 * [master^] Third
128 * [master~2] Second
129+*++ [initial] Initial
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700130EOF
131
brian m. carlson72f936b2020-02-07 00:52:40 +0000132process_diffs () {
133 _x04="[0-9a-f][0-9a-f][0-9a-f][0-9a-f]" &&
134 _x07="$_x05[0-9a-f][0-9a-f]" &&
135 sed -e "s/$OID_REGEX/$ZERO_OID/g" \
136 -e "s/From $_x40 /From $ZERO_OID /" \
137 -e "s/from $_x40)/from $ZERO_OID)/" \
138 -e "s/commit $_x40\$/commit $ZERO_OID/" \
139 -e "s/commit $_x40 (/commit $ZERO_OID (/" \
140 -e "s/$_x40 $_x40 $_x40/$ZERO_OID $ZERO_OID $ZERO_OID/" \
141 -e "s/$_x40 $_x40 /$ZERO_OID $ZERO_OID /" \
142 -e "s/^$_x40 $_x40$/$ZERO_OID $ZERO_OID/" \
143 -e "s/^$_x40 /$ZERO_OID /" \
144 -e "s/^$_x40$/$ZERO_OID/" \
145 -e "s/$_x07\.\.$_x07/fffffff..fffffff/g" \
146 -e "s/$_x07,$_x07\.\.$_x07/fffffff,fffffff..fffffff/g" \
147 -e "s/$_x07 $_x07 $_x07/fffffff fffffff fffffff/g" \
148 -e "s/$_x07 $_x07 /fffffff fffffff /g" \
149 -e "s/Merge: $_x07 $_x07/Merge: fffffff fffffff/g" \
150 -e "s/$_x07\.\.\./fffffff.../g" \
151 -e "s/ $_x04\.\.\./ ffff.../g" \
152 -e "s/ $_x04/ ffff/g" \
153 "$1"
154}
155
Elia Pinto4ff03342014-04-30 09:22:59 -0700156V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
Ann T Ropeab4c02c32017-12-03 22:27:41 +0100157while read magic cmd
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700158do
Ann T Ropeab4c02c32017-12-03 22:27:41 +0100159 case "$magic" in
160 '' | '#'*)
161 continue ;;
162 :*)
163 magic=${magic#:}
164 label="$magic-$cmd"
165 case "$magic" in
166 noellipses) ;;
167 *)
SZEDER Gábor165293a2018-11-19 14:13:26 +0100168 BUG "unknown magic $magic" ;;
Ann T Ropeab4c02c32017-12-03 22:27:41 +0100169 esac ;;
170 *)
171 cmd="$magic $cmd" magic=
172 label="$cmd" ;;
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700173 esac
Ann T Ropeab4c02c32017-12-03 22:27:41 +0100174 test=$(echo "$label" | sed -e 's|[/ ][/ ]*|_|g')
Elia Pinto4ff03342014-04-30 09:22:59 -0700175 pfx=$(printf "%04d" $test_count)
Junio C Hamanobfdbee92008-08-08 02:26:28 -0700176 expect="$TEST_DIRECTORY/t4013/diff.$test"
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700177 actual="$pfx-diff.$test"
178
Ævar Arnfjörð Bjarmasonde231e52018-08-28 19:38:26 +0000179 test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700180 {
Ann T Ropeab4c02c32017-12-03 22:27:41 +0100181 echo "$ git $cmd"
182 case "$magic" in
183 "")
184 GIT_PRINT_SHA1_ELLIPSIS=yes git $cmd ;;
185 noellipses)
186 git $cmd ;;
187 esac |
Junio C Hamano6c7f4ce2006-08-12 18:04:07 -0700188 sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
Junio C Hamano33ee4cf2007-03-04 16:08:04 -0800189 -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700190 echo "\$"
191 } >"$actual" &&
192 if test -f "$expect"
193 then
brian m. carlson72f936b2020-02-07 00:52:40 +0000194 process_diffs "$actual" >actual &&
195 process_diffs "$expect" >expect &&
Jonathan Nieder6dd88832012-03-13 00:05:54 -0500196 case $cmd in
197 *format-patch* | *-stat*)
brian m. carlson72f936b2020-02-07 00:52:40 +0000198 test_i18ncmp expect actual;;
Jonathan Nieder6dd88832012-03-13 00:05:54 -0500199 *)
brian m. carlson72f936b2020-02-07 00:52:40 +0000200 test_cmp expect actual;;
Jonathan Nieder6dd88832012-03-13 00:05:54 -0500201 esac &&
brian m. carlson72f936b2020-02-07 00:52:40 +0000202 rm -f "$actual" actual expect
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700203 else
204 # this is to help developing new tests.
205 cp "$actual" "$expect"
206 false
207 fi
208 '
209done <<\EOF
210diff-tree initial
211diff-tree -r initial
212diff-tree -r --abbrev initial
213diff-tree -r --abbrev=4 initial
214diff-tree --root initial
215diff-tree --root --abbrev initial
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100216:noellipses diff-tree --root --abbrev initial
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700217diff-tree --root -r initial
218diff-tree --root -r --abbrev initial
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100219:noellipses diff-tree --root -r --abbrev initial
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700220diff-tree --root -r --abbrev=4 initial
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100221:noellipses diff-tree --root -r --abbrev=4 initial
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700222diff-tree -p initial
223diff-tree --root -p initial
224diff-tree --patch-with-stat initial
225diff-tree --root --patch-with-stat initial
226diff-tree --patch-with-raw initial
227diff-tree --root --patch-with-raw initial
228
229diff-tree --pretty initial
230diff-tree --pretty --root initial
231diff-tree --pretty -p initial
232diff-tree --pretty --stat initial
233diff-tree --pretty --summary initial
234diff-tree --pretty --stat --summary initial
235diff-tree --pretty --root -p initial
236diff-tree --pretty --root --stat initial
Junio C Hamano026625e2006-06-29 12:00:12 -0700237# improved by Timo's patch
238diff-tree --pretty --root --summary initial
239# improved by Timo's patch
240diff-tree --pretty --root --summary -r initial
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700241diff-tree --pretty --root --stat --summary initial
242diff-tree --pretty --patch-with-stat initial
243diff-tree --pretty --root --patch-with-stat initial
244diff-tree --pretty --patch-with-raw initial
245diff-tree --pretty --root --patch-with-raw initial
246
247diff-tree --pretty=oneline initial
248diff-tree --pretty=oneline --root initial
249diff-tree --pretty=oneline -p initial
250diff-tree --pretty=oneline --root -p initial
251diff-tree --pretty=oneline --patch-with-stat initial
Junio C Hamano026625e2006-06-29 12:00:12 -0700252# improved by Timo's patch
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700253diff-tree --pretty=oneline --root --patch-with-stat initial
254diff-tree --pretty=oneline --patch-with-raw initial
255diff-tree --pretty=oneline --root --patch-with-raw initial
256
257diff-tree --pretty side
258diff-tree --pretty -p side
259diff-tree --pretty --patch-with-stat side
260
Stefan Beller58aaced2017-09-27 15:51:26 -0700261diff-tree initial mode
262diff-tree --stat initial mode
263diff-tree --summary initial mode
264
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700265diff-tree master
266diff-tree -p master
267diff-tree -p -m master
268diff-tree -c master
269diff-tree -c --abbrev master
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100270:noellipses diff-tree -c --abbrev master
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700271diff-tree --cc master
Junio C Hamano47979d52006-06-26 23:29:11 -0700272# stat only should show the diffstat with the first parent
273diff-tree -c --stat master
274diff-tree --cc --stat master
275diff-tree -c --stat --summary master
276diff-tree --cc --stat --summary master
277# stat summary should show the diffstat and summary with the first parent
278diff-tree -c --stat --summary side
279diff-tree --cc --stat --summary side
Jeff King8290faa2019-01-24 07:34:51 -0500280diff-tree --cc --shortstat master
Jeff King04b19fc2019-01-24 07:35:40 -0500281diff-tree --cc --summary REVERSE
Junio C Hamano026625e2006-06-29 12:00:12 -0700282# improved by Timo's patch
283diff-tree --cc --patch-with-stat master
284# improved by Timo's patch
Junio C Hamano47979d52006-06-26 23:29:11 -0700285diff-tree --cc --patch-with-stat --summary master
286# this is correct
287diff-tree --cc --patch-with-stat --summary side
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700288
289log master
290log -p master
291log --root master
292log --root -p master
293log --patch-with-stat master
294log --root --patch-with-stat master
Junio C Hamano47979d52006-06-26 23:29:11 -0700295log --root --patch-with-stat --summary master
Junio C Hamano026625e2006-06-29 12:00:12 -0700296# improved by Timo's patch
Junio C Hamano47979d52006-06-26 23:29:11 -0700297log --root -c --patch-with-stat --summary master
Junio C Hamano026625e2006-06-29 12:00:12 -0700298# improved by Timo's patch
Junio C Hamano47979d52006-06-26 23:29:11 -0700299log --root --cc --patch-with-stat --summary master
Junio C Hamano126f4312010-03-08 21:11:40 -0800300log -p --first-parent master
301log -m -p --first-parent master
302log -m -p master
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700303log -SF master
Matthieu Moydea007f2010-08-05 10:22:52 +0200304log -S F master
Junio C Hamano47979d52006-06-26 23:29:11 -0700305log -SF -p master
Matthieu Moy251df092011-03-09 21:52:15 +0100306log -SF master --max-count=0
307log -SF master --max-count=1
308log -SF master --max-count=2
Junio C Hamanobf1dfc32010-08-31 14:27:41 -0700309log -GF master
310log -GF -p master
311log -GF -p --pickaxe-all master
Thomas Rast28fd76b2009-02-19 12:13:40 +0100312log --decorate --all
Lars Hjemli33e70182009-08-15 16:23:12 +0200313log --decorate=full --all
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700314
Thomas Rastfcbc6ef2009-02-19 12:13:41 +0100315rev-list --parents HEAD
316rev-list --children HEAD
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700317
318whatchanged master
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100319:noellipses whatchanged master
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700320whatchanged -p master
321whatchanged --root master
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100322:noellipses whatchanged --root master
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700323whatchanged --root -p master
324whatchanged --patch-with-stat master
325whatchanged --root --patch-with-stat master
326whatchanged --root --patch-with-stat --summary master
Junio C Hamano026625e2006-06-29 12:00:12 -0700327# improved by Timo's patch
Junio C Hamano47979d52006-06-26 23:29:11 -0700328whatchanged --root -c --patch-with-stat --summary master
Junio C Hamano026625e2006-06-29 12:00:12 -0700329# improved by Timo's patch
Junio C Hamano47979d52006-06-26 23:29:11 -0700330whatchanged --root --cc --patch-with-stat --summary master
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700331whatchanged -SF master
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100332:noellipses whatchanged -SF master
Junio C Hamano47979d52006-06-26 23:29:11 -0700333whatchanged -SF -p master
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700334
335log --patch-with-stat master -- dir/
336whatchanged --patch-with-stat master -- dir/
Junio C Hamano47979d52006-06-26 23:29:11 -0700337log --patch-with-stat --summary master -- dir/
338whatchanged --patch-with-stat --summary master -- dir/
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700339
340show initial
341show --root initial
342show side
343show master
Junio C Hamanob4490052010-03-08 23:27:25 -0800344show -c master
Junio C Hamano2bf65872010-03-09 00:22:54 -0800345show -m master
346show --first-parent master
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700347show --stat side
348show --stat --summary side
349show --patch-with-stat side
350show --patch-with-raw side
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100351:noellipses show --patch-with-raw side
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700352show --patch-with-stat --summary side
353
Junio C Hamanod410e432006-06-29 00:01:07 -0700354format-patch --stdout initial..side
355format-patch --stdout initial..master^
356format-patch --stdout initial..master
Brian Gernhardta567fdc2008-10-02 16:55:39 -0400357format-patch --stdout --no-numbered initial..master
358format-patch --stdout --numbered initial..master
Junio C Hamanod410e432006-06-29 00:01:07 -0700359format-patch --attach --stdout initial..side
Stephen Boyd108dab22009-03-22 19:14:05 -0700360format-patch --attach --stdout --suffix=.diff initial..side
Junio C Hamanod410e432006-06-29 00:01:07 -0700361format-patch --attach --stdout initial..master^
362format-patch --attach --stdout initial..master
Johannes Schindelinc112f682007-03-04 00:12:06 +0100363format-patch --inline --stdout initial..side
364format-patch --inline --stdout initial..master^
Stephen Boyd747e2502009-03-22 19:14:06 -0700365format-patch --inline --stdout --numbered-files initial..master
Brian Gernhardta567fdc2008-10-02 16:55:39 -0400366format-patch --inline --stdout initial..master
Robin H. Johnson171ddd92007-04-11 16:58:08 -0700367format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
Adam Robendbd21442007-07-01 17:48:59 -0700368config format.subjectprefix DIFFERENT_PREFIX
369format-patch --inline --stdout initial..master^^
Daniel Barkalowa5a27c72008-02-18 22:56:13 -0500370format-patch --stdout --cover-letter -n initial..master^
Junio C Hamanod410e432006-06-29 00:01:07 -0700371
Junio C Hamanob319b022006-07-01 22:02:17 -0700372diff --abbrev initial..side
Nguyễn Thái Ngọc Duy8ef05192019-05-29 16:11:15 +0700373diff -U initial..side
374diff -U1 initial..side
Junio C Hamanob319b022006-07-01 22:02:17 -0700375diff -r initial..side
376diff --stat initial..side
377diff -r --stat initial..side
378diff initial..side
379diff --patch-with-stat initial..side
380diff --patch-with-raw initial..side
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100381:noellipses diff --patch-with-raw initial..side
Junio C Hamanob319b022006-07-01 22:02:17 -0700382diff --patch-with-stat -r initial..side
383diff --patch-with-raw -r initial..side
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100384:noellipses diff --patch-with-raw -r initial..side
Johannes Schindelin3cb56732007-07-03 16:01:06 +0100385diff --name-status dir2 dir
Junio C Hamano0569e9b2008-05-23 22:28:56 -0700386diff --no-index --name-status dir2 dir
Thomas Raste423ffd2009-01-06 19:53:32 +0100387diff --no-index --name-status -- dir2 dir
Michael Spangd61027b2009-02-18 01:48:06 -0500388diff --no-index dir dir3
Matt McCutchenb75271d2008-10-10 21:56:15 -0400389diff master master^ side
Jacob Keller660e1132016-08-31 16:27:20 -0700390# Can't use spaces...
391diff --line-prefix=abc master master^ side
Thomas Rastf37bfb72009-02-19 12:13:37 +0100392diff --dirstat master~1 master~2
Johan Herland204f01a2011-04-11 00:48:50 +0200393diff --dirstat initial rearrange
Johan Herland0133dab2011-04-11 00:48:51 +0200394diff --dirstat-by-file initial rearrange
Jeff Kingdac03b52019-01-24 07:36:47 -0500395diff --dirstat --cc master~1 master
Jack Bates43d19482016-12-06 09:56:14 -0700396# No-index --abbrev and --no-abbrev
397diff --raw initial
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100398:noellipses diff --raw initial
Jack Bates43d19482016-12-06 09:56:14 -0700399diff --raw --abbrev=4 initial
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100400:noellipses diff --raw --abbrev=4 initial
Jack Bates43d19482016-12-06 09:56:14 -0700401diff --raw --no-abbrev initial
402diff --no-index --raw dir2 dir
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100403:noellipses diff --no-index --raw dir2 dir
Jack Bates43d19482016-12-06 09:56:14 -0700404diff --no-index --raw --abbrev=4 dir2 dir
Ann T Ropeac2f1d392017-12-03 22:27:43 +0100405:noellipses diff --no-index --raw --abbrev=4 dir2 dir
Jack Bates43d19482016-12-06 09:56:14 -0700406diff --no-index --raw --no-abbrev dir2 dir
Nguyễn Thái Ngọc Duyddf88fa2018-02-24 21:09:59 +0700407
408diff-tree --pretty --root --stat --compact-summary initial
409diff-tree --pretty -R --root --stat --compact-summary initial
Taylor Blau5778b222020-04-20 18:13:15 -0600410diff-tree --pretty note
411diff-tree --pretty --notes note
412diff-tree --format=%N note
Nguyễn Thái Ngọc Duyddf88fa2018-02-24 21:09:59 +0700413diff-tree --stat --compact-summary initial mode
414diff-tree -R --stat --compact-summary initial mode
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700415EOF
416
Matthieu Moydea007f2010-08-05 10:22:52 +0200417test_expect_success 'log -S requires an argument' '
418 test_must_fail git log -S
419'
420
Nguyễn Thái Ngọc Duya2b7a3b2011-02-03 13:23:34 +0700421test_expect_success 'diff --cached on unborn branch' '
422 echo ref: refs/heads/unborn >.git/HEAD &&
423 git diff --cached >result &&
brian m. carlson72f936b2020-02-07 00:52:40 +0000424 process_diffs result >actual &&
425 process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached" >expected &&
426 test_cmp expected actual
Nguyễn Thái Ngọc Duya2b7a3b2011-02-03 13:23:34 +0700427'
428
429test_expect_success 'diff --cached -- file on unborn branch' '
430 git diff --cached -- file0 >result &&
brian m. carlson72f936b2020-02-07 00:52:40 +0000431 process_diffs result >actual &&
432 process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" >expected &&
433 test_cmp expected actual
Nguyễn Thái Ngọc Duya2b7a3b2011-02-03 13:23:34 +0700434'
Jacob Keller660e1132016-08-31 16:27:20 -0700435test_expect_success 'diff --line-prefix with spaces' '
436 git diff --line-prefix="| | | " --cached -- file0 >result &&
brian m. carlson72f936b2020-02-07 00:52:40 +0000437 process_diffs result >actual &&
438 process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" >expected &&
439 test_cmp expected actual
Jacob Keller660e1132016-08-31 16:27:20 -0700440'
Nguyễn Thái Ngọc Duya2b7a3b2011-02-03 13:23:34 +0700441
Jeff Kingd299e9e2014-07-28 14:01:57 -0400442test_expect_success 'diff-tree --stdin with log formatting' '
443 cat >expect <<-\EOF &&
444 Side
445 Third
446 Second
447 EOF
448 git rev-list master | git diff-tree --stdin --format=%s -s >actual &&
449 test_cmp expect actual
450'
451
Junio C Hamano3c2f75b2006-06-26 13:46:52 -0700452test_done