]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4013-diff-various.sh
RelNotes: spelling and phrasing fixups
[thirdparty/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
5404c116
MM
93 git config diff.renames false &&
94
3c2f75b5
JH
95 git show-branch
96'
97
98: <<\EOF
99! [initial] Initial
100 * [master] Merge branch 'side'
204f01a2
JH
101 ! [rearrange] Rearranged lines in dir/sub
102 ! [side] Side
103----
104 + [rearrange] Rearranged lines in dir/sub
105 - [master] Merge branch 'side'
106 * + [side] Side
107 * [master^] Third
108 * [master~2] Second
109+*++ [initial] Initial
3c2f75b5
JH
110EOF
111
4ff03347 112V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
3c2f75b5
JH
113while read cmd
114do
115 case "$cmd" in
116 '' | '#'*) continue ;;
117 esac
4ff03347
EP
118 test=$(echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g')
119 pfx=$(printf "%04d" $test_count)
bfdbee98 120 expect="$TEST_DIRECTORY/t4013/diff.$test"
3c2f75b5
JH
121 actual="$pfx-diff.$test"
122
123 test_expect_success "git $cmd" '
124 {
125 echo "\$ git $cmd"
6c7f4ceb
JH
126 git $cmd |
127 sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
33ee4cfb 128 -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
3c2f75b5
JH
129 echo "\$"
130 } >"$actual" &&
131 if test -f "$expect"
132 then
6dd88832
JN
133 case $cmd in
134 *format-patch* | *-stat*)
135 test_i18ncmp "$expect" "$actual";;
136 *)
137 test_cmp "$expect" "$actual";;
138 esac &&
3c2f75b5
JH
139 rm -f "$actual"
140 else
141 # this is to help developing new tests.
142 cp "$actual" "$expect"
143 false
144 fi
145 '
146done <<\EOF
147diff-tree initial
148diff-tree -r initial
149diff-tree -r --abbrev initial
150diff-tree -r --abbrev=4 initial
151diff-tree --root initial
152diff-tree --root --abbrev initial
153diff-tree --root -r initial
154diff-tree --root -r --abbrev initial
155diff-tree --root -r --abbrev=4 initial
156diff-tree -p initial
157diff-tree --root -p initial
158diff-tree --patch-with-stat initial
159diff-tree --root --patch-with-stat initial
160diff-tree --patch-with-raw initial
161diff-tree --root --patch-with-raw initial
162
163diff-tree --pretty initial
164diff-tree --pretty --root initial
165diff-tree --pretty -p initial
166diff-tree --pretty --stat initial
167diff-tree --pretty --summary initial
168diff-tree --pretty --stat --summary initial
169diff-tree --pretty --root -p initial
170diff-tree --pretty --root --stat initial
026625e7
JH
171# improved by Timo's patch
172diff-tree --pretty --root --summary initial
173# improved by Timo's patch
174diff-tree --pretty --root --summary -r initial
3c2f75b5
JH
175diff-tree --pretty --root --stat --summary initial
176diff-tree --pretty --patch-with-stat initial
177diff-tree --pretty --root --patch-with-stat initial
178diff-tree --pretty --patch-with-raw initial
179diff-tree --pretty --root --patch-with-raw initial
180
181diff-tree --pretty=oneline initial
182diff-tree --pretty=oneline --root initial
183diff-tree --pretty=oneline -p initial
184diff-tree --pretty=oneline --root -p initial
185diff-tree --pretty=oneline --patch-with-stat initial
026625e7 186# improved by Timo's patch
3c2f75b5
JH
187diff-tree --pretty=oneline --root --patch-with-stat initial
188diff-tree --pretty=oneline --patch-with-raw initial
189diff-tree --pretty=oneline --root --patch-with-raw initial
190
191diff-tree --pretty side
192diff-tree --pretty -p side
193diff-tree --pretty --patch-with-stat side
194
195diff-tree master
196diff-tree -p master
197diff-tree -p -m master
198diff-tree -c master
199diff-tree -c --abbrev master
200diff-tree --cc master
47979d5d
JH
201# stat only should show the diffstat with the first parent
202diff-tree -c --stat master
203diff-tree --cc --stat master
204diff-tree -c --stat --summary master
205diff-tree --cc --stat --summary master
206# stat summary should show the diffstat and summary with the first parent
207diff-tree -c --stat --summary side
208diff-tree --cc --stat --summary side
026625e7
JH
209# improved by Timo's patch
210diff-tree --cc --patch-with-stat master
211# improved by Timo's patch
47979d5d
JH
212diff-tree --cc --patch-with-stat --summary master
213# this is correct
214diff-tree --cc --patch-with-stat --summary side
3c2f75b5
JH
215
216log master
217log -p master
218log --root master
219log --root -p master
220log --patch-with-stat master
221log --root --patch-with-stat master
47979d5d 222log --root --patch-with-stat --summary master
026625e7 223# improved by Timo's patch
47979d5d 224log --root -c --patch-with-stat --summary master
026625e7 225# improved by Timo's patch
47979d5d 226log --root --cc --patch-with-stat --summary master
126f431a
JH
227log -p --first-parent master
228log -m -p --first-parent master
229log -m -p master
3c2f75b5 230log -SF master
dea007fb 231log -S F master
47979d5d 232log -SF -p master
251df09b
MM
233log -SF master --max-count=0
234log -SF master --max-count=1
235log -SF master --max-count=2
bf1dfc31
JH
236log -GF master
237log -GF -p master
238log -GF -p --pickaxe-all master
28fd76bd 239log --decorate --all
33e7018c 240log --decorate=full --all
3c2f75b5 241
fcbc6efc
TR
242rev-list --parents HEAD
243rev-list --children HEAD
3c2f75b5
JH
244
245whatchanged master
246whatchanged -p master
247whatchanged --root master
248whatchanged --root -p master
249whatchanged --patch-with-stat master
250whatchanged --root --patch-with-stat master
251whatchanged --root --patch-with-stat --summary master
026625e7 252# improved by Timo's patch
47979d5d 253whatchanged --root -c --patch-with-stat --summary master
026625e7 254# improved by Timo's patch
47979d5d 255whatchanged --root --cc --patch-with-stat --summary master
3c2f75b5 256whatchanged -SF master
47979d5d 257whatchanged -SF -p master
3c2f75b5
JH
258
259log --patch-with-stat master -- dir/
260whatchanged --patch-with-stat master -- dir/
47979d5d
JH
261log --patch-with-stat --summary master -- dir/
262whatchanged --patch-with-stat --summary master -- dir/
3c2f75b5
JH
263
264show initial
265show --root initial
266show side
267show master
b4490059 268show -c master
2bf65873
JH
269show -m master
270show --first-parent master
3c2f75b5
JH
271show --stat side
272show --stat --summary side
273show --patch-with-stat side
274show --patch-with-raw side
275show --patch-with-stat --summary side
276
d410e43b
JH
277format-patch --stdout initial..side
278format-patch --stdout initial..master^
279format-patch --stdout initial..master
a567fdcb
BG
280format-patch --stdout --no-numbered initial..master
281format-patch --stdout --numbered initial..master
d410e43b 282format-patch --attach --stdout initial..side
108dab28 283format-patch --attach --stdout --suffix=.diff initial..side
d410e43b
JH
284format-patch --attach --stdout initial..master^
285format-patch --attach --stdout initial..master
c112f689
JS
286format-patch --inline --stdout initial..side
287format-patch --inline --stdout initial..master^
747e2505 288format-patch --inline --stdout --numbered-files initial..master
a567fdcb 289format-patch --inline --stdout initial..master
171ddd91 290format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
dbd21447
AR
291config format.subjectprefix DIFFERENT_PREFIX
292format-patch --inline --stdout initial..master^^
a5a27c79 293format-patch --stdout --cover-letter -n initial..master^
d410e43b 294
b319b02e
JH
295diff --abbrev initial..side
296diff -r initial..side
297diff --stat initial..side
298diff -r --stat initial..side
299diff initial..side
300diff --patch-with-stat initial..side
301diff --patch-with-raw initial..side
302diff --patch-with-stat -r initial..side
303diff --patch-with-raw -r initial..side
3cb56738 304diff --name-status dir2 dir
0569e9b8 305diff --no-index --name-status dir2 dir
e423ffd8 306diff --no-index --name-status -- dir2 dir
d61027b2 307diff --no-index dir dir3
b75271d9 308diff master master^ side
660e113c
JK
309# Can't use spaces...
310diff --line-prefix=abc master master^ side
f37bfb7a 311diff --dirstat master~1 master~2
204f01a2 312diff --dirstat initial rearrange
0133dab7 313diff --dirstat-by-file initial rearrange
3c2f75b5
JH
314EOF
315
dea007fb
MM
316test_expect_success 'log -S requires an argument' '
317 test_must_fail git log -S
318'
319
a2b7a3b3
NTND
320test_expect_success 'diff --cached on unborn branch' '
321 echo ref: refs/heads/unborn >.git/HEAD &&
322 git diff --cached >result &&
323 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached" result
324'
325
326test_expect_success 'diff --cached -- file on unborn branch' '
327 git diff --cached -- file0 >result &&
328 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result
329'
660e113c
JK
330test_expect_success 'diff --line-prefix with spaces' '
331 git diff --line-prefix="| | | " --cached -- file0 >result &&
332 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" result
333'
a2b7a3b3 334
d299e9e5
JK
335test_expect_success 'diff-tree --stdin with log formatting' '
336 cat >expect <<-\EOF &&
337 Side
338 Third
339 Second
340 EOF
341 git rev-list master | git diff-tree --stdin --format=%s -s >actual &&
342 test_cmp expect actual
343'
344
3c2f75b5 345test_done