Merge branch 'jc/diff-mark'
[git/gitweb.git] / t / t4013-diff-various.sh
blob9eec754221d85856613b01ec878ef4cb492aceb0
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='Various diff formatting options'
8 . ./test-lib.sh
10 LF='
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 &&
19 mkdir dir &&
20 mkdir dir2 &&
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 &&
27 git branch initial &&
28 git branch side &&
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 &&
36 rm -f file2 &&
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 &&
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 &&
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 &&
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 &&
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 &&
77 git config log.showroot false &&
78 git commit --amend &&
79 git show-branch
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
91 EOF
93 V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
94 while read cmd
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`
102 expect="../t4013/diff.$test"
103 actual="$pfx-diff.$test"
105 test_expect_success "git $cmd" '
107 echo "\$ git $cmd"
108 git $cmd |
109 sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
110 -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
111 echo "\$"
112 } >"$actual" &&
113 if test -f "$expect"
114 then
115 git diff "$expect" "$actual" &&
116 rm -f "$actual"
117 else
118 # this is to help developing new tests.
119 cp "$actual" "$expect"
120 false
123 done <<\EOF
124 diff-tree initial
125 diff-tree -r initial
126 diff-tree -r --abbrev initial
127 diff-tree -r --abbrev=4 initial
128 diff-tree --root initial
129 diff-tree --root --abbrev initial
130 diff-tree --root -r initial
131 diff-tree --root -r --abbrev initial
132 diff-tree --root -r --abbrev=4 initial
133 diff-tree -p initial
134 diff-tree --root -p initial
135 diff-tree --patch-with-stat initial
136 diff-tree --root --patch-with-stat initial
137 diff-tree --patch-with-raw initial
138 diff-tree --root --patch-with-raw initial
140 diff-tree --pretty initial
141 diff-tree --pretty --root initial
142 diff-tree --pretty -p initial
143 diff-tree --pretty --stat initial
144 diff-tree --pretty --summary initial
145 diff-tree --pretty --stat --summary initial
146 diff-tree --pretty --root -p initial
147 diff-tree --pretty --root --stat initial
148 # improved by Timo's patch
149 diff-tree --pretty --root --summary initial
150 # improved by Timo's patch
151 diff-tree --pretty --root --summary -r initial
152 diff-tree --pretty --root --stat --summary initial
153 diff-tree --pretty --patch-with-stat initial
154 diff-tree --pretty --root --patch-with-stat initial
155 diff-tree --pretty --patch-with-raw initial
156 diff-tree --pretty --root --patch-with-raw initial
158 diff-tree --pretty=oneline initial
159 diff-tree --pretty=oneline --root initial
160 diff-tree --pretty=oneline -p initial
161 diff-tree --pretty=oneline --root -p initial
162 diff-tree --pretty=oneline --patch-with-stat initial
163 # improved by Timo's patch
164 diff-tree --pretty=oneline --root --patch-with-stat initial
165 diff-tree --pretty=oneline --patch-with-raw initial
166 diff-tree --pretty=oneline --root --patch-with-raw initial
168 diff-tree --pretty side
169 diff-tree --pretty -p side
170 diff-tree --pretty --patch-with-stat side
172 diff-tree master
173 diff-tree -p master
174 diff-tree -p -m master
175 diff-tree -c master
176 diff-tree -c --abbrev master
177 diff-tree --cc master
178 # stat only should show the diffstat with the first parent
179 diff-tree -c --stat master
180 diff-tree --cc --stat master
181 diff-tree -c --stat --summary master
182 diff-tree --cc --stat --summary master
183 # stat summary should show the diffstat and summary with the first parent
184 diff-tree -c --stat --summary side
185 diff-tree --cc --stat --summary side
186 # improved by Timo's patch
187 diff-tree --cc --patch-with-stat master
188 # improved by Timo's patch
189 diff-tree --cc --patch-with-stat --summary master
190 # this is correct
191 diff-tree --cc --patch-with-stat --summary side
193 log master
194 log -p master
195 log --root master
196 log --root -p master
197 log --patch-with-stat master
198 log --root --patch-with-stat master
199 log --root --patch-with-stat --summary master
200 # improved by Timo's patch
201 log --root -c --patch-with-stat --summary master
202 # improved by Timo's patch
203 log --root --cc --patch-with-stat --summary master
204 log -SF master
205 log -SF -p master
207 whatchanged master
208 whatchanged -p master
209 whatchanged --root master
210 whatchanged --root -p master
211 whatchanged --patch-with-stat master
212 whatchanged --root --patch-with-stat master
213 whatchanged --root --patch-with-stat --summary master
214 # improved by Timo's patch
215 whatchanged --root -c --patch-with-stat --summary master
216 # improved by Timo's patch
217 whatchanged --root --cc --patch-with-stat --summary master
218 whatchanged -SF master
219 whatchanged -SF -p master
221 log --patch-with-stat master -- dir/
222 whatchanged --patch-with-stat master -- dir/
223 log --patch-with-stat --summary master -- dir/
224 whatchanged --patch-with-stat --summary master -- dir/
226 show initial
227 show --root initial
228 show side
229 show master
230 show --stat side
231 show --stat --summary side
232 show --patch-with-stat side
233 show --patch-with-raw side
234 show --patch-with-stat --summary side
236 format-patch --stdout initial..side
237 format-patch --stdout initial..master^
238 format-patch --stdout initial..master
239 format-patch --attach --stdout initial..side
240 format-patch --attach --stdout initial..master^
241 format-patch --attach --stdout initial..master
242 format-patch --inline --stdout initial..side
243 format-patch --inline --stdout initial..master^
244 format-patch --inline --stdout initial..master
245 format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
246 config format.subjectprefix DIFFERENT_PREFIX
247 format-patch --inline --stdout initial..master^^
249 diff --abbrev initial..side
250 diff -r initial..side
251 diff --stat initial..side
252 diff -r --stat initial..side
253 diff initial..side
254 diff --patch-with-stat initial..side
255 diff --patch-with-raw initial..side
256 diff --patch-with-stat -r initial..side
257 diff --patch-with-raw -r initial..side
258 diff --name-status dir2 dir
261 test_done