diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value
[git/git.git] / t / t4013-diff-various.sh
CommitLineData
3c2f75b5
JH
1#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
6test_description='Various diff formatting options'
7
8. ./test-lib.sh
9
a40d384c
JH
10LF='
11'
12
3c2f75b5
JH
13test_expect_success setup '
14
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 &&
18
19 mkdir dir &&
3cb56738 20 mkdir dir2 &&
3c2f75b5
JH
21 for i in 1 2 3; do echo $i; done >file0 &&
22 for i in A B; do echo $i; done >dir/sub &&
23 cat file0 >file2 &&
24 git add file0 file2 dir/sub &&
25 git commit -m Initial &&
26
27 git branch initial &&
28 git branch side &&
29
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 &&
33
34 for i in 4 5 6; do echo $i; done >>file0 &&
35 for i in C D; do echo $i; done >>dir/sub &&
36 rm -f file2 &&
37 git update-index --remove file0 file2 dir/sub &&
a40d384c 38 git commit -m "Second${LF}${LF}This is the second commit." &&
3c2f75b5
JH
39
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 &&
43
44 for i in A B C; do echo $i; done >file1 &&
45 git add file1 &&
46 for i in E F; do echo $i; done >>dir/sub &&
47 git update-index dir/sub &&
48 git commit -m Third &&
49
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 &&
53
54 git checkout side &&
55 for i in A B C; do echo $i; done >>file0 &&
56 for i in 1 2; do echo $i; done >>dir/sub &&
57 cat dir/sub >file3 &&
58 git add file3 &&
59 git update-index file0 dir/sub &&
60 git commit -m Side &&
61
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 &&
65
66 git checkout master &&
67 git pull -s ours . side &&
68
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 &&
72
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 &&
76
d61027b2
MS
77 mkdir dir3 &&
78 cp dir/sub dir3/sub &&
79 test-chmtime +1 dir3/sub &&
80
e0d10e1c 81 git config log.showroot false &&
8ff99e74 82 git commit --amend &&
204f01a2
JH
83
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 &&
89 git add dir/sub &&
90 git commit -m "Rearranged lines in dir/sub" &&
91 git checkout master &&
92
58aaced4
SB
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 &&
100
5404c116
MM
101 git config diff.renames false &&
102
3c2f75b5
JH
103 git show-branch
104'
105
106: <<\EOF
107! [initial] Initial
108 * [master] Merge branch 'side'
204f01a2
JH
109 ! [rearrange] Rearranged lines in dir/sub
110 ! [side] Side
111----
112 + [rearrange] Rearranged lines in dir/sub
113 - [master] Merge branch 'side'
114 * + [side] Side
115 * [master^] Third
116 * [master~2] Second
117+*++ [initial] Initial
3c2f75b5
JH
118EOF
119
4ff03347 120V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
b4c02c30 121while read magic cmd
3c2f75b5 122do
b4c02c30
AR
123 case "$magic" in
124 '' | '#'*)
125 continue ;;
126 :*)
127 magic=${magic#:}
128 label="$magic-$cmd"
129 case "$magic" in
130 noellipses) ;;
131 *)
132 die "bug in t4103: unknown magic $magic" ;;
133 esac ;;
134 *)
135 cmd="$magic $cmd" magic=
136 label="$cmd" ;;
3c2f75b5 137 esac
b4c02c30 138 test=$(echo "$label" | sed -e 's|[/ ][/ ]*|_|g')
4ff03347 139 pfx=$(printf "%04d" $test_count)
bfdbee98 140 expect="$TEST_DIRECTORY/t4013/diff.$test"
3c2f75b5
JH
141 actual="$pfx-diff.$test"
142
143 test_expect_success "git $cmd" '
144 {
b4c02c30
AR
145 echo "$ git $cmd"
146 case "$magic" in
147 "")
148 GIT_PRINT_SHA1_ELLIPSIS=yes git $cmd ;;
149 noellipses)
150 git $cmd ;;
151 esac |
6c7f4ceb 152 sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
33ee4cfb 153 -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
3c2f75b5
JH
154 echo "\$"
155 } >"$actual" &&
156 if test -f "$expect"
157 then
6dd88832
JN
158 case $cmd in
159 *format-patch* | *-stat*)
160 test_i18ncmp "$expect" "$actual";;
161 *)
162 test_cmp "$expect" "$actual";;
163 esac &&
3c2f75b5
JH
164 rm -f "$actual"
165 else
166 # this is to help developing new tests.
167 cp "$actual" "$expect"
168 false
169 fi
170 '
171done <<\EOF
172diff-tree initial
173diff-tree -r initial
174diff-tree -r --abbrev initial
175diff-tree -r --abbrev=4 initial
176diff-tree --root initial
177diff-tree --root --abbrev initial
178diff-tree --root -r initial
179diff-tree --root -r --abbrev initial
180diff-tree --root -r --abbrev=4 initial
181diff-tree -p initial
182diff-tree --root -p initial
183diff-tree --patch-with-stat initial
184diff-tree --root --patch-with-stat initial
185diff-tree --patch-with-raw initial
186diff-tree --root --patch-with-raw initial
187
188diff-tree --pretty initial
189diff-tree --pretty --root initial
190diff-tree --pretty -p initial
191diff-tree --pretty --stat initial
192diff-tree --pretty --summary initial
193diff-tree --pretty --stat --summary initial
194diff-tree --pretty --root -p initial
195diff-tree --pretty --root --stat initial
026625e7
JH
196# improved by Timo's patch
197diff-tree --pretty --root --summary initial
198# improved by Timo's patch
199diff-tree --pretty --root --summary -r initial
3c2f75b5
JH
200diff-tree --pretty --root --stat --summary initial
201diff-tree --pretty --patch-with-stat initial
202diff-tree --pretty --root --patch-with-stat initial
203diff-tree --pretty --patch-with-raw initial
204diff-tree --pretty --root --patch-with-raw initial
205
206diff-tree --pretty=oneline initial
207diff-tree --pretty=oneline --root initial
208diff-tree --pretty=oneline -p initial
209diff-tree --pretty=oneline --root -p initial
210diff-tree --pretty=oneline --patch-with-stat initial
026625e7 211# improved by Timo's patch
3c2f75b5
JH
212diff-tree --pretty=oneline --root --patch-with-stat initial
213diff-tree --pretty=oneline --patch-with-raw initial
214diff-tree --pretty=oneline --root --patch-with-raw initial
215
216diff-tree --pretty side
217diff-tree --pretty -p side
218diff-tree --pretty --patch-with-stat side
219
58aaced4
SB
220diff-tree initial mode
221diff-tree --stat initial mode
222diff-tree --summary initial mode
223
3c2f75b5
JH
224diff-tree master
225diff-tree -p master
226diff-tree -p -m master
227diff-tree -c master
228diff-tree -c --abbrev master
229diff-tree --cc master
47979d5d
JH
230# stat only should show the diffstat with the first parent
231diff-tree -c --stat master
232diff-tree --cc --stat master
233diff-tree -c --stat --summary master
234diff-tree --cc --stat --summary master
235# stat summary should show the diffstat and summary with the first parent
236diff-tree -c --stat --summary side
237diff-tree --cc --stat --summary side
026625e7
JH
238# improved by Timo's patch
239diff-tree --cc --patch-with-stat master
240# improved by Timo's patch
47979d5d
JH
241diff-tree --cc --patch-with-stat --summary master
242# this is correct
243diff-tree --cc --patch-with-stat --summary side
3c2f75b5
JH
244
245log master
246log -p master
247log --root master
248log --root -p master
249log --patch-with-stat master
250log --root --patch-with-stat master
47979d5d 251log --root --patch-with-stat --summary master
026625e7 252# improved by Timo's patch
47979d5d 253log --root -c --patch-with-stat --summary master
026625e7 254# improved by Timo's patch
47979d5d 255log --root --cc --patch-with-stat --summary master
126f431a
JH
256log -p --first-parent master
257log -m -p --first-parent master
258log -m -p master
3c2f75b5 259log -SF master
dea007fb 260log -S F master
47979d5d 261log -SF -p master
251df09b
MM
262log -SF master --max-count=0
263log -SF master --max-count=1
264log -SF master --max-count=2
bf1dfc31
JH
265log -GF master
266log -GF -p master
267log -GF -p --pickaxe-all master
28fd76bd 268log --decorate --all
33e7018c 269log --decorate=full --all
3c2f75b5 270
fcbc6efc
TR
271rev-list --parents HEAD
272rev-list --children HEAD
3c2f75b5
JH
273
274whatchanged master
275whatchanged -p master
276whatchanged --root master
277whatchanged --root -p master
278whatchanged --patch-with-stat master
279whatchanged --root --patch-with-stat master
280whatchanged --root --patch-with-stat --summary master
026625e7 281# improved by Timo's patch
47979d5d 282whatchanged --root -c --patch-with-stat --summary master
026625e7 283# improved by Timo's patch
47979d5d 284whatchanged --root --cc --patch-with-stat --summary master
3c2f75b5 285whatchanged -SF master
47979d5d 286whatchanged -SF -p master
3c2f75b5
JH
287
288log --patch-with-stat master -- dir/
289whatchanged --patch-with-stat master -- dir/
47979d5d
JH
290log --patch-with-stat --summary master -- dir/
291whatchanged --patch-with-stat --summary master -- dir/
3c2f75b5
JH
292
293show initial
294show --root initial
295show side
296show master
b4490059 297show -c master
2bf65873
JH
298show -m master
299show --first-parent master
3c2f75b5
JH
300show --stat side
301show --stat --summary side
302show --patch-with-stat side
303show --patch-with-raw side
304show --patch-with-stat --summary side
305
d410e43b
JH
306format-patch --stdout initial..side
307format-patch --stdout initial..master^
308format-patch --stdout initial..master
a567fdcb
BG
309format-patch --stdout --no-numbered initial..master
310format-patch --stdout --numbered initial..master
d410e43b 311format-patch --attach --stdout initial..side
108dab28 312format-patch --attach --stdout --suffix=.diff initial..side
d410e43b
JH
313format-patch --attach --stdout initial..master^
314format-patch --attach --stdout initial..master
c112f689
JS
315format-patch --inline --stdout initial..side
316format-patch --inline --stdout initial..master^
747e2505 317format-patch --inline --stdout --numbered-files initial..master
a567fdcb 318format-patch --inline --stdout initial..master
171ddd91 319format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
dbd21447
AR
320config format.subjectprefix DIFFERENT_PREFIX
321format-patch --inline --stdout initial..master^^
a5a27c79 322format-patch --stdout --cover-letter -n initial..master^
d410e43b 323
b319b02e
JH
324diff --abbrev initial..side
325diff -r initial..side
326diff --stat initial..side
327diff -r --stat initial..side
328diff initial..side
329diff --patch-with-stat initial..side
330diff --patch-with-raw initial..side
331diff --patch-with-stat -r initial..side
332diff --patch-with-raw -r initial..side
3cb56738 333diff --name-status dir2 dir
0569e9b8 334diff --no-index --name-status dir2 dir
e423ffd8 335diff --no-index --name-status -- dir2 dir
d61027b2 336diff --no-index dir dir3
b75271d9 337diff master master^ side
660e113c
JK
338# Can't use spaces...
339diff --line-prefix=abc master master^ side
f37bfb7a 340diff --dirstat master~1 master~2
204f01a2 341diff --dirstat initial rearrange
0133dab7 342diff --dirstat-by-file initial rearrange
43d1948b
JB
343# No-index --abbrev and --no-abbrev
344diff --raw initial
345diff --raw --abbrev=4 initial
346diff --raw --no-abbrev initial
347diff --no-index --raw dir2 dir
348diff --no-index --raw --abbrev=4 dir2 dir
349diff --no-index --raw --no-abbrev dir2 dir
3c2f75b5
JH
350EOF
351
dea007fb
MM
352test_expect_success 'log -S requires an argument' '
353 test_must_fail git log -S
354'
355
a2b7a3b3
NTND
356test_expect_success 'diff --cached on unborn branch' '
357 echo ref: refs/heads/unborn >.git/HEAD &&
358 git diff --cached >result &&
359 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached" result
360'
361
362test_expect_success 'diff --cached -- file on unborn branch' '
363 git diff --cached -- file0 >result &&
364 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result
365'
660e113c
JK
366test_expect_success 'diff --line-prefix with spaces' '
367 git diff --line-prefix="| | | " --cached -- file0 >result &&
368 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" result
369'
a2b7a3b3 370
d299e9e5
JK
371test_expect_success 'diff-tree --stdin with log formatting' '
372 cat >expect <<-\EOF &&
373 Side
374 Third
375 Second
376 EOF
377 git rev-list master | git diff-tree --stdin --format=%s -s >actual &&
378 test_cmp expect actual
379'
380
3c2f75b5 381test_done