]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4013-diff-various.sh
Test that diff can read from stdin
[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
e0d10e1c 77 git config log.showroot false &&
8ff99e74 78 git commit --amend &&
3c2f75b5
JH
79 git show-branch
80'
81
82: <<\EOF
83! [initial] Initial
84 * [master] Merge branch 'side'
85 ! [side] Side
86---
87 - [master] Merge branch 'side'
88 *+ [side] Side
89 * [master^] Second
90+*+ [initial] Initial
91EOF
92
6c7f4ceb 93V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
3c2f75b5
JH
94while read cmd
95do
96 case "$cmd" in
97 '' | '#'*) continue ;;
98 esac
99 test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
100 cnt=`expr $test_count + 1`
101 pfx=`printf "%04d" $cnt`
bfdbee98 102 expect="$TEST_DIRECTORY/t4013/diff.$test"
3c2f75b5
JH
103 actual="$pfx-diff.$test"
104
105 test_expect_success "git $cmd" '
106 {
107 echo "\$ git $cmd"
6c7f4ceb
JH
108 git $cmd |
109 sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
33ee4cfb 110 -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
3c2f75b5
JH
111 echo "\$"
112 } >"$actual" &&
113 if test -f "$expect"
114 then
3af82863 115 test_cmp "$expect" "$actual" &&
3c2f75b5
JH
116 rm -f "$actual"
117 else
118 # this is to help developing new tests.
119 cp "$actual" "$expect"
120 false
121 fi
122 '
123done <<\EOF
124diff-tree initial
125diff-tree -r initial
126diff-tree -r --abbrev initial
127diff-tree -r --abbrev=4 initial
128diff-tree --root initial
129diff-tree --root --abbrev initial
130diff-tree --root -r initial
131diff-tree --root -r --abbrev initial
132diff-tree --root -r --abbrev=4 initial
133diff-tree -p initial
134diff-tree --root -p initial
135diff-tree --patch-with-stat initial
136diff-tree --root --patch-with-stat initial
137diff-tree --patch-with-raw initial
138diff-tree --root --patch-with-raw initial
139
140diff-tree --pretty initial
141diff-tree --pretty --root initial
142diff-tree --pretty -p initial
143diff-tree --pretty --stat initial
144diff-tree --pretty --summary initial
145diff-tree --pretty --stat --summary initial
146diff-tree --pretty --root -p initial
147diff-tree --pretty --root --stat initial
026625e7
JH
148# improved by Timo's patch
149diff-tree --pretty --root --summary initial
150# improved by Timo's patch
151diff-tree --pretty --root --summary -r initial
3c2f75b5
JH
152diff-tree --pretty --root --stat --summary initial
153diff-tree --pretty --patch-with-stat initial
154diff-tree --pretty --root --patch-with-stat initial
155diff-tree --pretty --patch-with-raw initial
156diff-tree --pretty --root --patch-with-raw initial
157
158diff-tree --pretty=oneline initial
159diff-tree --pretty=oneline --root initial
160diff-tree --pretty=oneline -p initial
161diff-tree --pretty=oneline --root -p initial
162diff-tree --pretty=oneline --patch-with-stat initial
026625e7 163# improved by Timo's patch
3c2f75b5
JH
164diff-tree --pretty=oneline --root --patch-with-stat initial
165diff-tree --pretty=oneline --patch-with-raw initial
166diff-tree --pretty=oneline --root --patch-with-raw initial
167
168diff-tree --pretty side
169diff-tree --pretty -p side
170diff-tree --pretty --patch-with-stat side
171
172diff-tree master
173diff-tree -p master
174diff-tree -p -m master
175diff-tree -c master
176diff-tree -c --abbrev master
177diff-tree --cc master
47979d5d
JH
178# stat only should show the diffstat with the first parent
179diff-tree -c --stat master
180diff-tree --cc --stat master
181diff-tree -c --stat --summary master
182diff-tree --cc --stat --summary master
183# stat summary should show the diffstat and summary with the first parent
184diff-tree -c --stat --summary side
185diff-tree --cc --stat --summary side
026625e7
JH
186# improved by Timo's patch
187diff-tree --cc --patch-with-stat master
188# improved by Timo's patch
47979d5d
JH
189diff-tree --cc --patch-with-stat --summary master
190# this is correct
191diff-tree --cc --patch-with-stat --summary side
3c2f75b5
JH
192
193log master
194log -p master
195log --root master
196log --root -p master
197log --patch-with-stat master
198log --root --patch-with-stat master
47979d5d 199log --root --patch-with-stat --summary master
026625e7 200# improved by Timo's patch
47979d5d 201log --root -c --patch-with-stat --summary master
026625e7 202# improved by Timo's patch
47979d5d 203log --root --cc --patch-with-stat --summary master
3c2f75b5 204log -SF master
47979d5d 205log -SF -p master
3c2f75b5
JH
206
207whatchanged master
208whatchanged -p master
209whatchanged --root master
210whatchanged --root -p master
211whatchanged --patch-with-stat master
212whatchanged --root --patch-with-stat master
213whatchanged --root --patch-with-stat --summary master
026625e7 214# improved by Timo's patch
47979d5d 215whatchanged --root -c --patch-with-stat --summary master
026625e7 216# improved by Timo's patch
47979d5d 217whatchanged --root --cc --patch-with-stat --summary master
3c2f75b5 218whatchanged -SF master
47979d5d 219whatchanged -SF -p master
3c2f75b5
JH
220
221log --patch-with-stat master -- dir/
222whatchanged --patch-with-stat master -- dir/
47979d5d
JH
223log --patch-with-stat --summary master -- dir/
224whatchanged --patch-with-stat --summary master -- dir/
3c2f75b5
JH
225
226show initial
227show --root initial
228show side
229show master
230show --stat side
231show --stat --summary side
232show --patch-with-stat side
233show --patch-with-raw side
234show --patch-with-stat --summary side
235
d410e43b
JH
236format-patch --stdout initial..side
237format-patch --stdout initial..master^
238format-patch --stdout initial..master
a567fdcb
BG
239format-patch --stdout --no-numbered initial..master
240format-patch --stdout --numbered initial..master
d410e43b
JH
241format-patch --attach --stdout initial..side
242format-patch --attach --stdout initial..master^
243format-patch --attach --stdout initial..master
c112f689
JS
244format-patch --inline --stdout initial..side
245format-patch --inline --stdout initial..master^
246format-patch --inline --stdout initial..master
a567fdcb 247format-patch --inline --stdout initial..master
171ddd91 248format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
dbd21447
AR
249config format.subjectprefix DIFFERENT_PREFIX
250format-patch --inline --stdout initial..master^^
a5a27c79 251format-patch --stdout --cover-letter -n initial..master^
d410e43b 252
b319b02e
JH
253diff --abbrev initial..side
254diff -r initial..side
255diff --stat initial..side
256diff -r --stat initial..side
257diff initial..side
258diff --patch-with-stat initial..side
259diff --patch-with-raw initial..side
260diff --patch-with-stat -r initial..side
261diff --patch-with-raw -r initial..side
3cb56738 262diff --name-status dir2 dir
0569e9b8 263diff --no-index --name-status dir2 dir
e423ffd8 264diff --no-index --name-status -- dir2 dir
b75271d9 265diff master master^ side
3c2f75b5
JH
266EOF
267
268test_done