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-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 config diff.renames false &&
100 * [master
] Merge branch
'side'
101 ! [rearrange
] Rearranged lines
in dir
/sub
104 + [rearrange
] Rearranged lines
in dir
/sub
105 - [master
] Merge branch
'side'
109 +*++ [initial
] Initial
112 V
=$
(git version |
sed -e 's/^git version //' -e 's/\./\\./g')
116 '' |
'#'*) continue ;;
118 test=$
(echo "$cmd" |
sed -e 's|[/ ][/ ]*|_|g')
119 pfx
=$
(printf "%04d" $test_count)
120 expect
="$TEST_DIRECTORY/t4013/diff.$test"
121 actual
="$pfx-diff.$test"
123 test_expect_success
"git $cmd" '
127 sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
128 -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
134 *format-patch* | *-stat*)
135 test_i18ncmp "$expect" "$actual";;
137 test_cmp "$expect" "$actual";;
141 # this is to help developing new tests.
142 cp "$actual" "$expect"
149 diff-tree
-r --abbrev initial
150 diff-tree
-r --abbrev=4 initial
151 diff-tree
--root initial
152 diff-tree
--root --abbrev initial
153 diff-tree
--root -r initial
154 diff-tree
--root -r --abbrev initial
155 diff-tree
--root -r --abbrev=4 initial
157 diff-tree
--root -p initial
158 diff-tree
--patch-with-stat initial
159 diff-tree
--root --patch-with-stat initial
160 diff-tree
--patch-with-raw initial
161 diff-tree
--root --patch-with-raw initial
163 diff-tree
--pretty initial
164 diff-tree
--pretty --root initial
165 diff-tree
--pretty -p initial
166 diff-tree
--pretty --stat initial
167 diff-tree
--pretty --summary initial
168 diff-tree
--pretty --stat --summary initial
169 diff-tree
--pretty --root -p initial
170 diff-tree
--pretty --root --stat initial
171 # improved by Timo's patch
172 diff-tree
--pretty --root --summary initial
173 # improved by Timo's patch
174 diff-tree
--pretty --root --summary -r initial
175 diff-tree
--pretty --root --stat --summary initial
176 diff-tree
--pretty --patch-with-stat initial
177 diff-tree
--pretty --root --patch-with-stat initial
178 diff-tree
--pretty --patch-with-raw initial
179 diff-tree
--pretty --root --patch-with-raw initial
181 diff-tree
--pretty=oneline initial
182 diff-tree
--pretty=oneline
--root initial
183 diff-tree
--pretty=oneline
-p initial
184 diff-tree
--pretty=oneline
--root -p initial
185 diff-tree
--pretty=oneline
--patch-with-stat initial
186 # improved by Timo's patch
187 diff-tree
--pretty=oneline
--root --patch-with-stat initial
188 diff-tree
--pretty=oneline
--patch-with-raw initial
189 diff-tree
--pretty=oneline
--root --patch-with-raw initial
191 diff-tree
--pretty side
192 diff-tree
--pretty -p side
193 diff-tree
--pretty --patch-with-stat side
197 diff-tree
-p -m master
199 diff-tree
-c --abbrev master
200 diff-tree
--cc master
201 # stat only should show the diffstat with the first parent
202 diff-tree
-c --stat master
203 diff-tree
--cc --stat master
204 diff-tree
-c --stat --summary master
205 diff-tree
--cc --stat --summary master
206 # stat summary should show the diffstat and summary with the first parent
207 diff-tree
-c --stat --summary side
208 diff-tree
--cc --stat --summary side
209 # improved by Timo's patch
210 diff-tree
--cc --patch-with-stat master
211 # improved by Timo's patch
212 diff-tree
--cc --patch-with-stat --summary master
214 diff-tree
--cc --patch-with-stat --summary side
220 log
--patch-with-stat master
221 log
--root --patch-with-stat master
222 log
--root --patch-with-stat --summary master
223 # improved by Timo's patch
224 log
--root -c --patch-with-stat --summary master
225 # improved by Timo's patch
226 log
--root --cc --patch-with-stat --summary master
227 log
-p --first-parent master
228 log
-m -p --first-parent master
233 log
-SF master
--max-count=0
234 log
-SF master
--max-count=1
235 log
-SF master
--max-count=2
238 log
-GF -p --pickaxe-all master
240 log
--decorate=full
--all
242 rev-list
--parents HEAD
243 rev-list
--children HEAD
246 whatchanged
-p master
247 whatchanged
--root master
248 whatchanged
--root -p master
249 whatchanged
--patch-with-stat master
250 whatchanged
--root --patch-with-stat master
251 whatchanged
--root --patch-with-stat --summary master
252 # improved by Timo's patch
253 whatchanged
--root -c --patch-with-stat --summary master
254 # improved by Timo's patch
255 whatchanged
--root --cc --patch-with-stat --summary master
256 whatchanged
-SF master
257 whatchanged
-SF -p master
259 log
--patch-with-stat master
-- dir
/
260 whatchanged
--patch-with-stat master
-- dir
/
261 log
--patch-with-stat --summary master
-- dir
/
262 whatchanged
--patch-with-stat --summary master
-- dir
/
270 show
--first-parent master
272 show
--stat --summary side
273 show
--patch-with-stat side
274 show
--patch-with-raw side
275 show
--patch-with-stat --summary side
277 format-patch
--stdout initial..side
278 format-patch
--stdout initial..master^
279 format-patch
--stdout initial..master
280 format-patch
--stdout --no-numbered initial..master
281 format-patch
--stdout --numbered initial..master
282 format-patch
--attach --stdout initial..side
283 format-patch
--attach --stdout --suffix=.
diff initial..side
284 format-patch
--attach --stdout initial..master^
285 format-patch
--attach --stdout initial..master
286 format-patch
--inline --stdout initial..side
287 format-patch
--inline --stdout initial..master^
288 format-patch
--inline --stdout --numbered-files initial..master
289 format-patch
--inline --stdout initial..master
290 format-patch
--inline --stdout --subject-prefix=TESTCASE initial..master
291 config format.subjectprefix DIFFERENT_PREFIX
292 format-patch
--inline --stdout initial..master^^
293 format-patch
--stdout --cover-letter -n initial..master^
295 diff --abbrev initial..side
296 diff -r initial..side
297 diff --stat initial..side
298 diff -r --stat initial..side
300 diff --patch-with-stat initial..side
301 diff --patch-with-raw initial..side
302 diff --patch-with-stat -r initial..side
303 diff --patch-with-raw -r initial..side
304 diff --name-status dir2 dir
305 diff --no-index --name-status dir2 dir
306 diff --no-index --name-status -- dir2 dir
307 diff --no-index dir dir3
308 diff master master^ side
309 diff --dirstat master~
1 master~
2
310 diff --dirstat initial rearrange
311 diff --dirstat-by-file initial rearrange
314 test_expect_success
'log -S requires an argument' '
315 test_must_fail git log -S
318 test_expect_success
'diff --cached on unborn branch' '
319 echo ref: refs/heads/unborn >.git/HEAD &&
320 git diff --cached >result &&
321 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached" result
324 test_expect_success
'diff --cached -- file on unborn branch' '
325 git diff --cached -- file0 >result &&
326 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result
329 test_expect_success
'diff-tree --stdin with log formatting' '
330 cat >expect <<-\EOF &&
335 git rev-list master | git diff-tree --stdin --format=%s -s >actual &&
336 test_cmp expect actual