t4013: add more tests around -c and --cc
[git/git.git] / t / t4013-diff-various.sh
CommitLineData
3c2f75b5
JH
1#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
6test_description='Various diff formatting options'
7
8. ./test-lib.sh
9
10test_expect_success setup '
11
12 GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
13 GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
14 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
15
16 mkdir dir &&
17 for i in 1 2 3; do echo $i; done >file0 &&
18 for i in A B; do echo $i; done >dir/sub &&
19 cat file0 >file2 &&
20 git add file0 file2 dir/sub &&
21 git commit -m Initial &&
22
23 git branch initial &&
24 git branch side &&
25
26 GIT_AUTHOR_DATE="2006-06-26 00:01:00 +0000" &&
27 GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" &&
28 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
29
30 for i in 4 5 6; do echo $i; done >>file0 &&
31 for i in C D; do echo $i; done >>dir/sub &&
32 rm -f file2 &&
33 git update-index --remove file0 file2 dir/sub &&
34 git commit -m Second &&
35
36 GIT_AUTHOR_DATE="2006-06-26 00:02:00 +0000" &&
37 GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" &&
38 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
39
40 for i in A B C; do echo $i; done >file1 &&
41 git add file1 &&
42 for i in E F; do echo $i; done >>dir/sub &&
43 git update-index dir/sub &&
44 git commit -m Third &&
45
46 GIT_AUTHOR_DATE="2006-06-26 00:03:00 +0000" &&
47 GIT_COMMITTER_DATE="2006-06-26 00:03:00 +0000" &&
48 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
49
50 git checkout side &&
51 for i in A B C; do echo $i; done >>file0 &&
52 for i in 1 2; do echo $i; done >>dir/sub &&
53 cat dir/sub >file3 &&
54 git add file3 &&
55 git update-index file0 dir/sub &&
56 git commit -m Side &&
57
58 GIT_AUTHOR_DATE="2006-06-26 00:04:00 +0000" &&
59 GIT_COMMITTER_DATE="2006-06-26 00:04:00 +0000" &&
60 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
61
62 git checkout master &&
63 git pull -s ours . side &&
64
65 GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" &&
66 GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" &&
67 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
68
69 for i in A B C; do echo $i; done >>file0 &&
70 for i in 1 2; do echo $i; done >>dir/sub &&
71 git update-index file0 dir/sub &&
72
73 EDITOR=: VISUAL=: git commit --amend &&
74 git show-branch
75'
76
77: <<\EOF
78! [initial] Initial
79 * [master] Merge branch 'side'
80 ! [side] Side
81---
82 - [master] Merge branch 'side'
83 *+ [side] Side
84 * [master^] Second
85+*+ [initial] Initial
86EOF
87
88while read cmd
89do
90 case "$cmd" in
91 '' | '#'*) continue ;;
92 esac
93 test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
94 cnt=`expr $test_count + 1`
95 pfx=`printf "%04d" $cnt`
96 expect="../t4013/diff.$test"
97 actual="$pfx-diff.$test"
98
99 test_expect_success "git $cmd" '
100 {
101 echo "\$ git $cmd"
102 git $cmd
103 echo "\$"
104 } >"$actual" &&
105 if test -f "$expect"
106 then
107 diff -u "$expect" "$actual" &&
108 rm -f "$actual"
109 else
110 # this is to help developing new tests.
111 cp "$actual" "$expect"
112 false
113 fi
114 '
115done <<\EOF
116diff-tree initial
117diff-tree -r initial
118diff-tree -r --abbrev initial
119diff-tree -r --abbrev=4 initial
120diff-tree --root initial
121diff-tree --root --abbrev initial
122diff-tree --root -r initial
123diff-tree --root -r --abbrev initial
124diff-tree --root -r --abbrev=4 initial
125diff-tree -p initial
126diff-tree --root -p initial
127diff-tree --patch-with-stat initial
128diff-tree --root --patch-with-stat initial
129diff-tree --patch-with-raw initial
130diff-tree --root --patch-with-raw initial
131
132diff-tree --pretty initial
133diff-tree --pretty --root initial
134diff-tree --pretty -p initial
135diff-tree --pretty --stat initial
136diff-tree --pretty --summary initial
137diff-tree --pretty --stat --summary initial
138diff-tree --pretty --root -p initial
139diff-tree --pretty --root --stat initial
140#diff-tree --pretty --root --summary initial
141diff-tree --pretty --root --stat --summary initial
142diff-tree --pretty --patch-with-stat initial
143diff-tree --pretty --root --patch-with-stat initial
144diff-tree --pretty --patch-with-raw initial
145diff-tree --pretty --root --patch-with-raw initial
146
147diff-tree --pretty=oneline initial
148diff-tree --pretty=oneline --root initial
149diff-tree --pretty=oneline -p initial
150diff-tree --pretty=oneline --root -p initial
151diff-tree --pretty=oneline --patch-with-stat initial
152diff-tree --pretty=oneline --root --patch-with-stat initial
153diff-tree --pretty=oneline --patch-with-raw initial
154diff-tree --pretty=oneline --root --patch-with-raw initial
155
156diff-tree --pretty side
157diff-tree --pretty -p side
158diff-tree --pretty --patch-with-stat side
159
160diff-tree master
161diff-tree -p master
162diff-tree -p -m master
163diff-tree -c master
164diff-tree -c --abbrev master
165diff-tree --cc master
47979d5d
JH
166# stat only should show the diffstat with the first parent
167diff-tree -c --stat master
168diff-tree --cc --stat master
169diff-tree -c --stat --summary master
170diff-tree --cc --stat --summary master
171# stat summary should show the diffstat and summary with the first parent
172diff-tree -c --stat --summary side
173diff-tree --cc --stat --summary side
174# this one gives an extra newline after stat, which should be removed
175# diff-tree --cc --patch-with-stat master
176# this one gives an extra newline after stat, which should be removed
177# other than that it shows the correct example -- stat and summary are
178# against the first parent, and patch-looking combined diff follows.
179diff-tree --cc --patch-with-stat --summary master
180# this is correct
181diff-tree --cc --patch-with-stat --summary side
3c2f75b5
JH
182
183log master
184log -p master
185log --root master
186log --root -p master
187log --patch-with-stat master
188log --root --patch-with-stat master
47979d5d
JH
189log --root --patch-with-stat --summary master
190log --root -c --patch-with-stat --summary master
191log --root --cc --patch-with-stat --summary master
3c2f75b5 192log -SF master
47979d5d 193log -SF -p master
3c2f75b5
JH
194
195whatchanged master
196whatchanged -p master
197whatchanged --root master
198whatchanged --root -p master
199whatchanged --patch-with-stat master
200whatchanged --root --patch-with-stat master
201whatchanged --root --patch-with-stat --summary master
47979d5d
JH
202whatchanged --root -c --patch-with-stat --summary master
203whatchanged --root --cc --patch-with-stat --summary master
3c2f75b5 204whatchanged -SF master
47979d5d 205whatchanged -SF -p master
3c2f75b5
JH
206
207log --patch-with-stat master -- dir/
208whatchanged --patch-with-stat master -- dir/
47979d5d
JH
209log --patch-with-stat --summary master -- dir/
210whatchanged --patch-with-stat --summary master -- dir/
3c2f75b5
JH
211
212show initial
213show --root initial
214show side
215show master
216show --stat side
217show --stat --summary side
218show --patch-with-stat side
219show --patch-with-raw side
220show --patch-with-stat --summary side
221
3c2f75b5
JH
222EOF
223
224test_done