Merge tag 'l10n-2.10.0-rnd2.2' of git://github.com/git-l10n/git-po
[git/debian.git] / t / t4013-diff-various.sh
blob94ef5000e787f0898ff6ccb57661c972c765db52
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 mkdir dir3 &&
78 cp dir/sub dir3/sub &&
79 test-chmtime +1 dir3/sub &&
81 git config log.showroot false &&
82 git commit --amend &&
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 &&
93 git config diff.renames false &&
95 git show-branch
98 : <<\EOF
99 ! [initial] Initial
100 * [master] Merge branch 'side'
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
112 V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
113 while read cmd
115 case "$cmd" in
116 '' | '#'*) continue ;;
117 esac
118 test=$(echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g')
119 pfx=$(printf "%04d" $test_count)
120 expect="$TEST_DIRECTORY/t4013/diff.$test"
121 actual="$pfx-diff.$test"
123 test_expect_success "git $cmd" '
125 echo "\$ git $cmd"
126 git $cmd |
127 sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
128 -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
129 echo "\$"
130 } >"$actual" &&
131 if test -f "$expect"
132 then
133 case $cmd in
134 *format-patch* | *-stat*)
135 test_i18ncmp "$expect" "$actual";;
137 test_cmp "$expect" "$actual";;
138 esac &&
139 rm -f "$actual"
140 else
141 # this is to help developing new tests.
142 cp "$actual" "$expect"
143 false
146 done <<\EOF
147 diff-tree initial
148 diff-tree -r initial
149 diff-tree -r --abbrev initial
150 diff-tree -r --abbrev=4 initial
151 diff-tree --root initial
152 diff-tree --root --abbrev initial
153 diff-tree --root -r initial
154 diff-tree --root -r --abbrev initial
155 diff-tree --root -r --abbrev=4 initial
156 diff-tree -p initial
157 diff-tree --root -p initial
158 diff-tree --patch-with-stat initial
159 diff-tree --root --patch-with-stat initial
160 diff-tree --patch-with-raw initial
161 diff-tree --root --patch-with-raw initial
163 diff-tree --pretty initial
164 diff-tree --pretty --root initial
165 diff-tree --pretty -p initial
166 diff-tree --pretty --stat initial
167 diff-tree --pretty --summary initial
168 diff-tree --pretty --stat --summary initial
169 diff-tree --pretty --root -p initial
170 diff-tree --pretty --root --stat initial
171 # improved by Timo's patch
172 diff-tree --pretty --root --summary initial
173 # improved by Timo's patch
174 diff-tree --pretty --root --summary -r initial
175 diff-tree --pretty --root --stat --summary initial
176 diff-tree --pretty --patch-with-stat initial
177 diff-tree --pretty --root --patch-with-stat initial
178 diff-tree --pretty --patch-with-raw initial
179 diff-tree --pretty --root --patch-with-raw initial
181 diff-tree --pretty=oneline initial
182 diff-tree --pretty=oneline --root initial
183 diff-tree --pretty=oneline -p initial
184 diff-tree --pretty=oneline --root -p initial
185 diff-tree --pretty=oneline --patch-with-stat initial
186 # improved by Timo's patch
187 diff-tree --pretty=oneline --root --patch-with-stat initial
188 diff-tree --pretty=oneline --patch-with-raw initial
189 diff-tree --pretty=oneline --root --patch-with-raw initial
191 diff-tree --pretty side
192 diff-tree --pretty -p side
193 diff-tree --pretty --patch-with-stat side
195 diff-tree master
196 diff-tree -p master
197 diff-tree -p -m master
198 diff-tree -c master
199 diff-tree -c --abbrev master
200 diff-tree --cc master
201 # stat only should show the diffstat with the first parent
202 diff-tree -c --stat master
203 diff-tree --cc --stat master
204 diff-tree -c --stat --summary master
205 diff-tree --cc --stat --summary master
206 # stat summary should show the diffstat and summary with the first parent
207 diff-tree -c --stat --summary side
208 diff-tree --cc --stat --summary side
209 # improved by Timo's patch
210 diff-tree --cc --patch-with-stat master
211 # improved by Timo's patch
212 diff-tree --cc --patch-with-stat --summary master
213 # this is correct
214 diff-tree --cc --patch-with-stat --summary side
216 log master
217 log -p master
218 log --root master
219 log --root -p master
220 log --patch-with-stat master
221 log --root --patch-with-stat master
222 log --root --patch-with-stat --summary master
223 # improved by Timo's patch
224 log --root -c --patch-with-stat --summary master
225 # improved by Timo's patch
226 log --root --cc --patch-with-stat --summary master
227 log -p --first-parent master
228 log -m -p --first-parent master
229 log -m -p master
230 log -SF master
231 log -S F master
232 log -SF -p master
233 log -SF master --max-count=0
234 log -SF master --max-count=1
235 log -SF master --max-count=2
236 log -GF master
237 log -GF -p master
238 log -GF -p --pickaxe-all master
239 log --decorate --all
240 log --decorate=full --all
242 rev-list --parents HEAD
243 rev-list --children HEAD
245 whatchanged master
246 whatchanged -p master
247 whatchanged --root master
248 whatchanged --root -p master
249 whatchanged --patch-with-stat master
250 whatchanged --root --patch-with-stat master
251 whatchanged --root --patch-with-stat --summary master
252 # improved by Timo's patch
253 whatchanged --root -c --patch-with-stat --summary master
254 # improved by Timo's patch
255 whatchanged --root --cc --patch-with-stat --summary master
256 whatchanged -SF master
257 whatchanged -SF -p master
259 log --patch-with-stat master -- dir/
260 whatchanged --patch-with-stat master -- dir/
261 log --patch-with-stat --summary master -- dir/
262 whatchanged --patch-with-stat --summary master -- dir/
264 show initial
265 show --root initial
266 show side
267 show master
268 show -c master
269 show -m master
270 show --first-parent master
271 show --stat side
272 show --stat --summary side
273 show --patch-with-stat side
274 show --patch-with-raw side
275 show --patch-with-stat --summary side
277 format-patch --stdout initial..side
278 format-patch --stdout initial..master^
279 format-patch --stdout initial..master
280 format-patch --stdout --no-numbered initial..master
281 format-patch --stdout --numbered initial..master
282 format-patch --attach --stdout initial..side
283 format-patch --attach --stdout --suffix=.diff initial..side
284 format-patch --attach --stdout initial..master^
285 format-patch --attach --stdout initial..master
286 format-patch --inline --stdout initial..side
287 format-patch --inline --stdout initial..master^
288 format-patch --inline --stdout --numbered-files initial..master
289 format-patch --inline --stdout initial..master
290 format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
291 config format.subjectprefix DIFFERENT_PREFIX
292 format-patch --inline --stdout initial..master^^
293 format-patch --stdout --cover-letter -n initial..master^
295 diff --abbrev initial..side
296 diff -r initial..side
297 diff --stat initial..side
298 diff -r --stat initial..side
299 diff initial..side
300 diff --patch-with-stat initial..side
301 diff --patch-with-raw initial..side
302 diff --patch-with-stat -r initial..side
303 diff --patch-with-raw -r initial..side
304 diff --name-status dir2 dir
305 diff --no-index --name-status dir2 dir
306 diff --no-index --name-status -- dir2 dir
307 diff --no-index dir dir3
308 diff master master^ side
309 diff --dirstat master~1 master~2
310 diff --dirstat initial rearrange
311 diff --dirstat-by-file initial rearrange
314 test_expect_success 'log -S requires an argument' '
315 test_must_fail git log -S
318 test_expect_success 'diff --cached on unborn branch' '
319 echo ref: refs/heads/unborn >.git/HEAD &&
320 git diff --cached >result &&
321 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached" result
324 test_expect_success 'diff --cached -- file on unborn branch' '
325 git diff --cached -- file0 >result &&
326 test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result
329 test_expect_success 'diff-tree --stdin with log formatting' '
330 cat >expect <<-\EOF &&
331 Side
332 Third
333 Second
335 git rev-list master | git diff-tree --stdin --format=%s -s >actual &&
336 test_cmp expect actual
339 test_done