rebase: teach --autosquash to match on sha1 in addition to message
[git/kirr.git] / t / t4013-diff-various.sh
blob19857f4326aa491a4c7d292900a0a766e7c45f80
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 &&
83 git show-branch
86 : <<\EOF
87 ! [initial] Initial
88 * [master] Merge branch 'side'
89 ! [side] Side
90 ---
91 - [master] Merge branch 'side'
92 *+ [side] Side
93 * [master^] Second
94 +*+ [initial] Initial
95 EOF
97 V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
98 while read cmd
100 case "$cmd" in
101 '' | '#'*) continue ;;
102 esac
103 test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
104 pfx=`printf "%04d" $test_count`
105 expect="$TEST_DIRECTORY/t4013/diff.$test"
106 actual="$pfx-diff.$test"
108 test_expect_success "git $cmd" '
110 echo "\$ git $cmd"
111 git $cmd |
112 sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
113 -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
114 echo "\$"
115 } >"$actual" &&
116 if test -f "$expect"
117 then
118 test_cmp "$expect" "$actual" &&
119 rm -f "$actual"
120 else
121 # this is to help developing new tests.
122 cp "$actual" "$expect"
123 false
126 done <<\EOF
127 diff-tree initial
128 diff-tree -r initial
129 diff-tree -r --abbrev initial
130 diff-tree -r --abbrev=4 initial
131 diff-tree --root initial
132 diff-tree --root --abbrev initial
133 diff-tree --root -r initial
134 diff-tree --root -r --abbrev initial
135 diff-tree --root -r --abbrev=4 initial
136 diff-tree -p initial
137 diff-tree --root -p initial
138 diff-tree --patch-with-stat initial
139 diff-tree --root --patch-with-stat initial
140 diff-tree --patch-with-raw initial
141 diff-tree --root --patch-with-raw initial
143 diff-tree --pretty initial
144 diff-tree --pretty --root initial
145 diff-tree --pretty -p initial
146 diff-tree --pretty --stat initial
147 diff-tree --pretty --summary initial
148 diff-tree --pretty --stat --summary initial
149 diff-tree --pretty --root -p initial
150 diff-tree --pretty --root --stat initial
151 # improved by Timo's patch
152 diff-tree --pretty --root --summary initial
153 # improved by Timo's patch
154 diff-tree --pretty --root --summary -r initial
155 diff-tree --pretty --root --stat --summary initial
156 diff-tree --pretty --patch-with-stat initial
157 diff-tree --pretty --root --patch-with-stat initial
158 diff-tree --pretty --patch-with-raw initial
159 diff-tree --pretty --root --patch-with-raw initial
161 diff-tree --pretty=oneline initial
162 diff-tree --pretty=oneline --root initial
163 diff-tree --pretty=oneline -p initial
164 diff-tree --pretty=oneline --root -p initial
165 diff-tree --pretty=oneline --patch-with-stat initial
166 # improved by Timo's patch
167 diff-tree --pretty=oneline --root --patch-with-stat initial
168 diff-tree --pretty=oneline --patch-with-raw initial
169 diff-tree --pretty=oneline --root --patch-with-raw initial
171 diff-tree --pretty side
172 diff-tree --pretty -p side
173 diff-tree --pretty --patch-with-stat side
175 diff-tree master
176 diff-tree -p master
177 diff-tree -p -m master
178 diff-tree -c master
179 diff-tree -c --abbrev master
180 diff-tree --cc master
181 # stat only should show the diffstat with the first parent
182 diff-tree -c --stat master
183 diff-tree --cc --stat master
184 diff-tree -c --stat --summary master
185 diff-tree --cc --stat --summary master
186 # stat summary should show the diffstat and summary with the first parent
187 diff-tree -c --stat --summary side
188 diff-tree --cc --stat --summary side
189 # improved by Timo's patch
190 diff-tree --cc --patch-with-stat master
191 # improved by Timo's patch
192 diff-tree --cc --patch-with-stat --summary master
193 # this is correct
194 diff-tree --cc --patch-with-stat --summary side
196 log master
197 log -p master
198 log --root master
199 log --root -p master
200 log --patch-with-stat master
201 log --root --patch-with-stat master
202 log --root --patch-with-stat --summary master
203 # improved by Timo's patch
204 log --root -c --patch-with-stat --summary master
205 # improved by Timo's patch
206 log --root --cc --patch-with-stat --summary master
207 log -p --first-parent master
208 log -m -p --first-parent master
209 log -m -p master
210 log -SF master
211 log -S F master
212 log -SF -p master
213 log --decorate --all
214 log --decorate=full --all
216 rev-list --parents HEAD
217 rev-list --children HEAD
219 whatchanged master
220 whatchanged -p master
221 whatchanged --root master
222 whatchanged --root -p master
223 whatchanged --patch-with-stat master
224 whatchanged --root --patch-with-stat master
225 whatchanged --root --patch-with-stat --summary master
226 # improved by Timo's patch
227 whatchanged --root -c --patch-with-stat --summary master
228 # improved by Timo's patch
229 whatchanged --root --cc --patch-with-stat --summary master
230 whatchanged -SF master
231 whatchanged -SF -p master
233 log --patch-with-stat master -- dir/
234 whatchanged --patch-with-stat master -- dir/
235 log --patch-with-stat --summary master -- dir/
236 whatchanged --patch-with-stat --summary master -- dir/
238 show initial
239 show --root initial
240 show side
241 show master
242 show -c master
243 show -m master
244 show --first-parent master
245 show --stat side
246 show --stat --summary side
247 show --patch-with-stat side
248 show --patch-with-raw side
249 show --patch-with-stat --summary side
251 format-patch --stdout initial..side
252 format-patch --stdout initial..master^
253 format-patch --stdout initial..master
254 format-patch --stdout --no-numbered initial..master
255 format-patch --stdout --numbered initial..master
256 format-patch --attach --stdout initial..side
257 format-patch --attach --stdout --suffix=.diff initial..side
258 format-patch --attach --stdout initial..master^
259 format-patch --attach --stdout initial..master
260 format-patch --inline --stdout initial..side
261 format-patch --inline --stdout initial..master^
262 format-patch --inline --stdout --numbered-files initial..master
263 format-patch --inline --stdout initial..master
264 format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
265 config format.subjectprefix DIFFERENT_PREFIX
266 format-patch --inline --stdout initial..master^^
267 format-patch --stdout --cover-letter -n initial..master^
269 diff --abbrev initial..side
270 diff -r initial..side
271 diff --stat initial..side
272 diff -r --stat initial..side
273 diff initial..side
274 diff --patch-with-stat initial..side
275 diff --patch-with-raw initial..side
276 diff --patch-with-stat -r initial..side
277 diff --patch-with-raw -r initial..side
278 diff --name-status dir2 dir
279 diff --no-index --name-status dir2 dir
280 diff --no-index --name-status -- dir2 dir
281 diff --no-index dir dir3
282 diff master master^ side
283 diff --dirstat master~1 master~2
286 test_expect_success 'log -S requires an argument' '
287 test_must_fail git log -S
290 test_done