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