]>
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 | ||
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 | |
91 | EOF | |
92 | ||
6c7f4ceb | 93 | V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'` |
3c2f75b5 JH |
94 | while read cmd |
95 | do | |
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" | |
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 | ' | |
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 | |
139 | ||
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 | |
026625e7 JH |
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 | |
3c2f75b5 JH |
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 | |
157 | ||
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 | |
026625e7 | 163 | # improved by Timo's patch |
3c2f75b5 JH |
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 | |
167 | ||
168 | diff-tree --pretty side | |
169 | diff-tree --pretty -p side | |
170 | diff-tree --pretty --patch-with-stat side | |
171 | ||
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 | |
47979d5d JH |
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 | |
026625e7 JH |
186 | # improved by Timo's patch |
187 | diff-tree --cc --patch-with-stat master | |
188 | # improved by Timo's patch | |
47979d5d JH |
189 | diff-tree --cc --patch-with-stat --summary master |
190 | # this is correct | |
191 | diff-tree --cc --patch-with-stat --summary side | |
3c2f75b5 JH |
192 | |
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 | |
47979d5d | 199 | log --root --patch-with-stat --summary master |
026625e7 | 200 | # improved by Timo's patch |
47979d5d | 201 | log --root -c --patch-with-stat --summary master |
026625e7 | 202 | # improved by Timo's patch |
47979d5d | 203 | log --root --cc --patch-with-stat --summary master |
3c2f75b5 | 204 | log -SF master |
47979d5d | 205 | log -SF -p master |
3c2f75b5 JH |
206 | |
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 | |
026625e7 | 214 | # improved by Timo's patch |
47979d5d | 215 | whatchanged --root -c --patch-with-stat --summary master |
026625e7 | 216 | # improved by Timo's patch |
47979d5d | 217 | whatchanged --root --cc --patch-with-stat --summary master |
3c2f75b5 | 218 | whatchanged -SF master |
47979d5d | 219 | whatchanged -SF -p master |
3c2f75b5 JH |
220 | |
221 | log --patch-with-stat master -- dir/ | |
222 | whatchanged --patch-with-stat master -- dir/ | |
47979d5d JH |
223 | log --patch-with-stat --summary master -- dir/ |
224 | whatchanged --patch-with-stat --summary master -- dir/ | |
3c2f75b5 JH |
225 | |
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 | |
235 | ||
d410e43b JH |
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 | |
c112f689 JS |
242 | format-patch --inline --stdout initial..side |
243 | format-patch --inline --stdout initial..master^ | |
244 | format-patch --inline --stdout initial..master | |
171ddd91 | 245 | format-patch --inline --stdout --subject-prefix=TESTCASE initial..master |
dbd21447 AR |
246 | config format.subjectprefix DIFFERENT_PREFIX |
247 | format-patch --inline --stdout initial..master^^ | |
a5a27c79 | 248 | format-patch --stdout --cover-letter -n initial..master^ |
d410e43b | 249 | |
b319b02e JH |
250 | diff --abbrev initial..side |
251 | diff -r initial..side | |
252 | diff --stat initial..side | |
253 | diff -r --stat initial..side | |
254 | diff initial..side | |
255 | diff --patch-with-stat initial..side | |
256 | diff --patch-with-raw initial..side | |
257 | diff --patch-with-stat -r initial..side | |
258 | diff --patch-with-raw -r initial..side | |
3cb56738 | 259 | diff --name-status dir2 dir |
3c2f75b5 JH |
260 | EOF |
261 | ||
262 | test_done |