]>
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 && | |
20 | for i in 1 2 3; do echo $i; done >file0 && | |
21 | for i in A B; do echo $i; done >dir/sub && | |
22 | cat file0 >file2 && | |
23 | git add file0 file2 dir/sub && | |
24 | git commit -m Initial && | |
25 | ||
26 | git branch initial && | |
27 | git branch side && | |
28 | ||
29 | GIT_AUTHOR_DATE="2006-06-26 00:01:00 +0000" && | |
30 | GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" && | |
31 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
32 | ||
33 | for i in 4 5 6; do echo $i; done >>file0 && | |
34 | for i in C D; do echo $i; done >>dir/sub && | |
35 | rm -f file2 && | |
36 | git update-index --remove file0 file2 dir/sub && | |
a40d384c | 37 | git commit -m "Second${LF}${LF}This is the second commit." && |
3c2f75b5 JH |
38 | |
39 | GIT_AUTHOR_DATE="2006-06-26 00:02:00 +0000" && | |
40 | GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" && | |
41 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
42 | ||
43 | for i in A B C; do echo $i; done >file1 && | |
44 | git add file1 && | |
45 | for i in E F; do echo $i; done >>dir/sub && | |
46 | git update-index dir/sub && | |
47 | git commit -m Third && | |
48 | ||
49 | GIT_AUTHOR_DATE="2006-06-26 00:03:00 +0000" && | |
50 | GIT_COMMITTER_DATE="2006-06-26 00:03:00 +0000" && | |
51 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
52 | ||
53 | git checkout side && | |
54 | for i in A B C; do echo $i; done >>file0 && | |
55 | for i in 1 2; do echo $i; done >>dir/sub && | |
56 | cat dir/sub >file3 && | |
57 | git add file3 && | |
58 | git update-index file0 dir/sub && | |
59 | git commit -m Side && | |
60 | ||
61 | GIT_AUTHOR_DATE="2006-06-26 00:04:00 +0000" && | |
62 | GIT_COMMITTER_DATE="2006-06-26 00:04:00 +0000" && | |
63 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
64 | ||
65 | git checkout master && | |
66 | git pull -s ours . side && | |
67 | ||
68 | GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" && | |
69 | GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" && | |
70 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
71 | ||
72 | for i in A B C; do echo $i; done >>file0 && | |
73 | for i in 1 2; do echo $i; done >>dir/sub && | |
74 | git update-index file0 dir/sub && | |
75 | ||
e0d10e1c | 76 | git config log.showroot false && |
8ff99e74 | 77 | git commit --amend && |
3c2f75b5 JH |
78 | git show-branch |
79 | ' | |
80 | ||
81 | : <<\EOF | |
82 | ! [initial] Initial | |
83 | * [master] Merge branch 'side' | |
84 | ! [side] Side | |
85 | --- | |
86 | - [master] Merge branch 'side' | |
87 | *+ [side] Side | |
88 | * [master^] Second | |
89 | +*+ [initial] Initial | |
90 | EOF | |
91 | ||
6c7f4ceb | 92 | V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'` |
3c2f75b5 JH |
93 | while read cmd |
94 | do | |
95 | case "$cmd" in | |
96 | '' | '#'*) continue ;; | |
97 | esac | |
98 | test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'` | |
99 | cnt=`expr $test_count + 1` | |
100 | pfx=`printf "%04d" $cnt` | |
101 | expect="../t4013/diff.$test" | |
102 | actual="$pfx-diff.$test" | |
103 | ||
104 | test_expect_success "git $cmd" ' | |
105 | { | |
106 | echo "\$ git $cmd" | |
6c7f4ceb JH |
107 | git $cmd | |
108 | sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \ | |
109 | -e "s/^\\( *boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/" | |
3c2f75b5 JH |
110 | echo "\$" |
111 | } >"$actual" && | |
112 | if test -f "$expect" | |
113 | then | |
114 | diff -u "$expect" "$actual" && | |
115 | rm -f "$actual" | |
116 | else | |
117 | # this is to help developing new tests. | |
118 | cp "$actual" "$expect" | |
119 | false | |
120 | fi | |
121 | ' | |
122 | done <<\EOF | |
123 | diff-tree initial | |
124 | diff-tree -r initial | |
125 | diff-tree -r --abbrev initial | |
126 | diff-tree -r --abbrev=4 initial | |
127 | diff-tree --root initial | |
128 | diff-tree --root --abbrev initial | |
129 | diff-tree --root -r initial | |
130 | diff-tree --root -r --abbrev initial | |
131 | diff-tree --root -r --abbrev=4 initial | |
132 | diff-tree -p initial | |
133 | diff-tree --root -p initial | |
134 | diff-tree --patch-with-stat initial | |
135 | diff-tree --root --patch-with-stat initial | |
136 | diff-tree --patch-with-raw initial | |
137 | diff-tree --root --patch-with-raw initial | |
138 | ||
139 | diff-tree --pretty initial | |
140 | diff-tree --pretty --root initial | |
141 | diff-tree --pretty -p initial | |
142 | diff-tree --pretty --stat initial | |
143 | diff-tree --pretty --summary initial | |
144 | diff-tree --pretty --stat --summary initial | |
145 | diff-tree --pretty --root -p initial | |
146 | diff-tree --pretty --root --stat initial | |
026625e7 JH |
147 | # improved by Timo's patch |
148 | diff-tree --pretty --root --summary initial | |
149 | # improved by Timo's patch | |
150 | diff-tree --pretty --root --summary -r initial | |
3c2f75b5 JH |
151 | diff-tree --pretty --root --stat --summary initial |
152 | diff-tree --pretty --patch-with-stat initial | |
153 | diff-tree --pretty --root --patch-with-stat initial | |
154 | diff-tree --pretty --patch-with-raw initial | |
155 | diff-tree --pretty --root --patch-with-raw initial | |
156 | ||
157 | diff-tree --pretty=oneline initial | |
158 | diff-tree --pretty=oneline --root initial | |
159 | diff-tree --pretty=oneline -p initial | |
160 | diff-tree --pretty=oneline --root -p initial | |
161 | diff-tree --pretty=oneline --patch-with-stat initial | |
026625e7 | 162 | # improved by Timo's patch |
3c2f75b5 JH |
163 | diff-tree --pretty=oneline --root --patch-with-stat initial |
164 | diff-tree --pretty=oneline --patch-with-raw initial | |
165 | diff-tree --pretty=oneline --root --patch-with-raw initial | |
166 | ||
167 | diff-tree --pretty side | |
168 | diff-tree --pretty -p side | |
169 | diff-tree --pretty --patch-with-stat side | |
170 | ||
171 | diff-tree master | |
172 | diff-tree -p master | |
173 | diff-tree -p -m master | |
174 | diff-tree -c master | |
175 | diff-tree -c --abbrev master | |
176 | diff-tree --cc master | |
47979d5d JH |
177 | # stat only should show the diffstat with the first parent |
178 | diff-tree -c --stat master | |
179 | diff-tree --cc --stat master | |
180 | diff-tree -c --stat --summary master | |
181 | diff-tree --cc --stat --summary master | |
182 | # stat summary should show the diffstat and summary with the first parent | |
183 | diff-tree -c --stat --summary side | |
184 | diff-tree --cc --stat --summary side | |
026625e7 JH |
185 | # improved by Timo's patch |
186 | diff-tree --cc --patch-with-stat master | |
187 | # improved by Timo's patch | |
47979d5d JH |
188 | diff-tree --cc --patch-with-stat --summary master |
189 | # this is correct | |
190 | diff-tree --cc --patch-with-stat --summary side | |
3c2f75b5 JH |
191 | |
192 | log master | |
193 | log -p master | |
194 | log --root master | |
195 | log --root -p master | |
196 | log --patch-with-stat master | |
197 | log --root --patch-with-stat master | |
47979d5d | 198 | log --root --patch-with-stat --summary master |
026625e7 | 199 | # improved by Timo's patch |
47979d5d | 200 | log --root -c --patch-with-stat --summary master |
026625e7 | 201 | # improved by Timo's patch |
47979d5d | 202 | log --root --cc --patch-with-stat --summary master |
3c2f75b5 | 203 | log -SF master |
47979d5d | 204 | log -SF -p master |
3c2f75b5 JH |
205 | |
206 | whatchanged master | |
207 | whatchanged -p master | |
208 | whatchanged --root master | |
209 | whatchanged --root -p master | |
210 | whatchanged --patch-with-stat master | |
211 | whatchanged --root --patch-with-stat master | |
212 | whatchanged --root --patch-with-stat --summary master | |
026625e7 | 213 | # improved by Timo's patch |
47979d5d | 214 | whatchanged --root -c --patch-with-stat --summary master |
026625e7 | 215 | # improved by Timo's patch |
47979d5d | 216 | whatchanged --root --cc --patch-with-stat --summary master |
3c2f75b5 | 217 | whatchanged -SF master |
47979d5d | 218 | whatchanged -SF -p master |
3c2f75b5 JH |
219 | |
220 | log --patch-with-stat master -- dir/ | |
221 | whatchanged --patch-with-stat master -- dir/ | |
47979d5d JH |
222 | log --patch-with-stat --summary master -- dir/ |
223 | whatchanged --patch-with-stat --summary master -- dir/ | |
3c2f75b5 JH |
224 | |
225 | show initial | |
226 | show --root initial | |
227 | show side | |
228 | show master | |
229 | show --stat side | |
230 | show --stat --summary side | |
231 | show --patch-with-stat side | |
232 | show --patch-with-raw side | |
233 | show --patch-with-stat --summary side | |
234 | ||
d410e43b JH |
235 | format-patch --stdout initial..side |
236 | format-patch --stdout initial..master^ | |
237 | format-patch --stdout initial..master | |
238 | format-patch --attach --stdout initial..side | |
239 | format-patch --attach --stdout initial..master^ | |
240 | format-patch --attach --stdout initial..master | |
c112f689 JS |
241 | format-patch --inline --stdout initial..side |
242 | format-patch --inline --stdout initial..master^ | |
243 | format-patch --inline --stdout initial..master | |
d410e43b | 244 | |
b319b02e JH |
245 | diff --abbrev initial..side |
246 | diff -r initial..side | |
247 | diff --stat initial..side | |
248 | diff -r --stat initial..side | |
249 | diff initial..side | |
250 | diff --patch-with-stat initial..side | |
251 | diff --patch-with-raw initial..side | |
252 | diff --patch-with-stat -r initial..side | |
253 | diff --patch-with-raw -r initial..side | |
3c2f75b5 JH |
254 | EOF |
255 | ||
256 | test_done |