]>
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 | ||
8ff99e74 | 76 | git commit --amend && |
3c2f75b5 JH |
77 | git show-branch |
78 | ' | |
79 | ||
80 | : <<\EOF | |
81 | ! [initial] Initial | |
82 | * [master] Merge branch 'side' | |
83 | ! [side] Side | |
84 | --- | |
85 | - [master] Merge branch 'side' | |
86 | *+ [side] Side | |
87 | * [master^] Second | |
88 | +*+ [initial] Initial | |
89 | EOF | |
90 | ||
d410e43b | 91 | V=`git version | sed -e 's/^git version //'` |
3c2f75b5 JH |
92 | while read cmd |
93 | do | |
94 | case "$cmd" in | |
95 | '' | '#'*) continue ;; | |
96 | esac | |
97 | test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'` | |
98 | cnt=`expr $test_count + 1` | |
99 | pfx=`printf "%04d" $cnt` | |
100 | expect="../t4013/diff.$test" | |
101 | actual="$pfx-diff.$test" | |
102 | ||
103 | test_expect_success "git $cmd" ' | |
104 | { | |
105 | echo "\$ git $cmd" | |
d410e43b | 106 | git $cmd | sed -e "s/$V/g-i-t--v-e-r-s-i-o-n/" |
3c2f75b5 JH |
107 | echo "\$" |
108 | } >"$actual" && | |
109 | if test -f "$expect" | |
110 | then | |
111 | diff -u "$expect" "$actual" && | |
112 | rm -f "$actual" | |
113 | else | |
114 | # this is to help developing new tests. | |
115 | cp "$actual" "$expect" | |
116 | false | |
117 | fi | |
118 | ' | |
119 | done <<\EOF | |
120 | diff-tree initial | |
121 | diff-tree -r initial | |
122 | diff-tree -r --abbrev initial | |
123 | diff-tree -r --abbrev=4 initial | |
124 | diff-tree --root initial | |
125 | diff-tree --root --abbrev initial | |
126 | diff-tree --root -r initial | |
127 | diff-tree --root -r --abbrev initial | |
128 | diff-tree --root -r --abbrev=4 initial | |
129 | diff-tree -p initial | |
130 | diff-tree --root -p initial | |
131 | diff-tree --patch-with-stat initial | |
132 | diff-tree --root --patch-with-stat initial | |
133 | diff-tree --patch-with-raw initial | |
134 | diff-tree --root --patch-with-raw initial | |
135 | ||
136 | diff-tree --pretty initial | |
137 | diff-tree --pretty --root initial | |
138 | diff-tree --pretty -p initial | |
139 | diff-tree --pretty --stat initial | |
140 | diff-tree --pretty --summary initial | |
141 | diff-tree --pretty --stat --summary initial | |
142 | diff-tree --pretty --root -p initial | |
143 | diff-tree --pretty --root --stat initial | |
026625e7 JH |
144 | # improved by Timo's patch |
145 | diff-tree --pretty --root --summary initial | |
146 | # improved by Timo's patch | |
147 | diff-tree --pretty --root --summary -r initial | |
3c2f75b5 JH |
148 | diff-tree --pretty --root --stat --summary initial |
149 | diff-tree --pretty --patch-with-stat initial | |
150 | diff-tree --pretty --root --patch-with-stat initial | |
151 | diff-tree --pretty --patch-with-raw initial | |
152 | diff-tree --pretty --root --patch-with-raw initial | |
153 | ||
154 | diff-tree --pretty=oneline initial | |
155 | diff-tree --pretty=oneline --root initial | |
156 | diff-tree --pretty=oneline -p initial | |
157 | diff-tree --pretty=oneline --root -p initial | |
158 | diff-tree --pretty=oneline --patch-with-stat initial | |
026625e7 | 159 | # improved by Timo's patch |
3c2f75b5 JH |
160 | diff-tree --pretty=oneline --root --patch-with-stat initial |
161 | diff-tree --pretty=oneline --patch-with-raw initial | |
162 | diff-tree --pretty=oneline --root --patch-with-raw initial | |
163 | ||
164 | diff-tree --pretty side | |
165 | diff-tree --pretty -p side | |
166 | diff-tree --pretty --patch-with-stat side | |
167 | ||
168 | diff-tree master | |
169 | diff-tree -p master | |
170 | diff-tree -p -m master | |
171 | diff-tree -c master | |
172 | diff-tree -c --abbrev master | |
173 | diff-tree --cc master | |
47979d5d JH |
174 | # stat only should show the diffstat with the first parent |
175 | diff-tree -c --stat master | |
176 | diff-tree --cc --stat master | |
177 | diff-tree -c --stat --summary master | |
178 | diff-tree --cc --stat --summary master | |
179 | # stat summary should show the diffstat and summary with the first parent | |
180 | diff-tree -c --stat --summary side | |
181 | diff-tree --cc --stat --summary side | |
026625e7 JH |
182 | # improved by Timo's patch |
183 | diff-tree --cc --patch-with-stat master | |
184 | # improved by Timo's patch | |
47979d5d JH |
185 | diff-tree --cc --patch-with-stat --summary master |
186 | # this is correct | |
187 | diff-tree --cc --patch-with-stat --summary side | |
3c2f75b5 JH |
188 | |
189 | log master | |
190 | log -p master | |
191 | log --root master | |
192 | log --root -p master | |
193 | log --patch-with-stat master | |
194 | log --root --patch-with-stat master | |
47979d5d | 195 | log --root --patch-with-stat --summary master |
026625e7 | 196 | # improved by Timo's patch |
47979d5d | 197 | log --root -c --patch-with-stat --summary master |
026625e7 | 198 | # improved by Timo's patch |
47979d5d | 199 | log --root --cc --patch-with-stat --summary master |
3c2f75b5 | 200 | log -SF master |
47979d5d | 201 | log -SF -p master |
3c2f75b5 JH |
202 | |
203 | whatchanged master | |
204 | whatchanged -p master | |
205 | whatchanged --root master | |
206 | whatchanged --root -p master | |
207 | whatchanged --patch-with-stat master | |
208 | whatchanged --root --patch-with-stat master | |
209 | whatchanged --root --patch-with-stat --summary master | |
026625e7 | 210 | # improved by Timo's patch |
47979d5d | 211 | whatchanged --root -c --patch-with-stat --summary master |
026625e7 | 212 | # improved by Timo's patch |
47979d5d | 213 | whatchanged --root --cc --patch-with-stat --summary master |
3c2f75b5 | 214 | whatchanged -SF master |
47979d5d | 215 | whatchanged -SF -p master |
3c2f75b5 JH |
216 | |
217 | log --patch-with-stat master -- dir/ | |
218 | whatchanged --patch-with-stat master -- dir/ | |
47979d5d JH |
219 | log --patch-with-stat --summary master -- dir/ |
220 | whatchanged --patch-with-stat --summary master -- dir/ | |
3c2f75b5 JH |
221 | |
222 | show initial | |
223 | show --root initial | |
224 | show side | |
225 | show master | |
226 | show --stat side | |
227 | show --stat --summary side | |
228 | show --patch-with-stat side | |
229 | show --patch-with-raw side | |
230 | show --patch-with-stat --summary side | |
231 | ||
d410e43b JH |
232 | format-patch --stdout initial..side |
233 | format-patch --stdout initial..master^ | |
234 | format-patch --stdout initial..master | |
235 | format-patch --attach --stdout initial..side | |
236 | format-patch --attach --stdout initial..master^ | |
237 | format-patch --attach --stdout initial..master | |
238 | ||
b319b02e JH |
239 | diff --abbrev initial..side |
240 | diff -r initial..side | |
241 | diff --stat initial..side | |
242 | diff -r --stat initial..side | |
243 | diff initial..side | |
244 | diff --patch-with-stat initial..side | |
245 | diff --patch-with-raw initial..side | |
246 | diff --patch-with-stat -r initial..side | |
247 | diff --patch-with-raw -r initial..side | |
3c2f75b5 JH |
248 | EOF |
249 | ||
250 | test_done |