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