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