Skip to content

Commit 3c2f75b

Browse files
author
Junio C Hamano
committed
t4013: add tests for diff/log family output options.
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 1ef9e05 commit 3c2f75b

File tree

72 files changed

+2579
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2579
-0
lines changed

t/t4013-diff-various.sh

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
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+
10+
test_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
86+
EOF
87+
88+
while read cmd
89+
do
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+
'
115+
done <<\EOF
116+
diff-tree initial
117+
diff-tree -r initial
118+
diff-tree -r --abbrev initial
119+
diff-tree -r --abbrev=4 initial
120+
diff-tree --root initial
121+
diff-tree --root --abbrev initial
122+
diff-tree --root -r initial
123+
diff-tree --root -r --abbrev initial
124+
diff-tree --root -r --abbrev=4 initial
125+
diff-tree -p initial
126+
diff-tree --root -p initial
127+
diff-tree --patch-with-stat initial
128+
diff-tree --root --patch-with-stat initial
129+
diff-tree --patch-with-raw initial
130+
diff-tree --root --patch-with-raw initial
131+
132+
diff-tree --pretty initial
133+
diff-tree --pretty --root initial
134+
diff-tree --pretty -p initial
135+
diff-tree --pretty --stat initial
136+
diff-tree --pretty --summary initial
137+
diff-tree --pretty --stat --summary initial
138+
diff-tree --pretty --root -p initial
139+
diff-tree --pretty --root --stat initial
140+
#diff-tree --pretty --root --summary initial
141+
diff-tree --pretty --root --stat --summary initial
142+
diff-tree --pretty --patch-with-stat initial
143+
diff-tree --pretty --root --patch-with-stat initial
144+
diff-tree --pretty --patch-with-raw initial
145+
diff-tree --pretty --root --patch-with-raw initial
146+
147+
diff-tree --pretty=oneline initial
148+
diff-tree --pretty=oneline --root initial
149+
diff-tree --pretty=oneline -p initial
150+
diff-tree --pretty=oneline --root -p initial
151+
diff-tree --pretty=oneline --patch-with-stat initial
152+
diff-tree --pretty=oneline --root --patch-with-stat initial
153+
diff-tree --pretty=oneline --patch-with-raw initial
154+
diff-tree --pretty=oneline --root --patch-with-raw initial
155+
156+
diff-tree --pretty side
157+
diff-tree --pretty -p side
158+
diff-tree --pretty --patch-with-stat side
159+
160+
diff-tree master
161+
diff-tree -p master
162+
diff-tree -p -m master
163+
diff-tree -c master
164+
diff-tree -c --abbrev master
165+
diff-tree --cc master
166+
167+
log master
168+
log -p master
169+
log --root master
170+
log --root -p master
171+
log --patch-with-stat master
172+
log --root --patch-with-stat master
173+
#log --root --patch-with-stat --summary master
174+
log -SF master
175+
176+
whatchanged master
177+
whatchanged -p master
178+
whatchanged --root master
179+
whatchanged --root -p master
180+
whatchanged --patch-with-stat master
181+
whatchanged --root --patch-with-stat master
182+
whatchanged --root --patch-with-stat --summary master
183+
whatchanged -SF master
184+
185+
log --patch-with-stat master -- dir/
186+
whatchanged --patch-with-stat master -- dir/
187+
188+
show initial
189+
show --root initial
190+
show side
191+
show master
192+
show --stat side
193+
show --stat --summary side
194+
show --patch-with-stat side
195+
show --patch-with-raw side
196+
show --patch-with-stat --summary side
197+
198+
199+
200+
EOF
201+
202+
test_done

t/t4013/diff.diff-tree_--cc_master

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$ git diff-tree --cc master
2+
176b998f5d647cbd77a9d8acf4531e930754d16d
3+
diff --cc dir/sub
4+
index cead32e,7289e35..992913c
5+
--- a/dir/sub
6+
+++ b/dir/sub
7+
@@@ -1,6 -1,4 +1,8 @@@
8+
A
9+
B
10+
+C
11+
+D
12+
+E
13+
+F
14+
+ 1
15+
+ 2
16+
diff --cc file0
17+
index b414108,f4615da..10a8a9f
18+
--- a/file0
19+
+++ b/file0
20+
@@@ -1,6 -1,6 +1,9 @@@
21+
1
22+
2
23+
3
24+
+4
25+
+5
26+
+6
27+
+ A
28+
+ B
29+
+ C
30+
$
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ git diff-tree --patch-with-raw initial
2+
$
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ git diff-tree --patch-with-stat initial
2+
$
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ git diff-tree --pretty=oneline --patch-with-raw initial
2+
$
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ git diff-tree --pretty=oneline --patch-with-stat initial
2+
$
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
$ git diff-tree --pretty=oneline --root --patch-with-raw initial
2+
444ac553ac7612cc88969031b02b3767fb8a353a Initial
3+
:000000 100644 0000000000000000000000000000000000000000 35d242ba79ae89ac695e26b3d4c27a8e6f028f9e A dir/sub
4+
:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0
5+
:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2
6+
7+
diff --git a/dir/sub b/dir/sub
8+
new file mode 100644
9+
index 0000000..35d242b
10+
--- /dev/null
11+
+++ b/dir/sub
12+
@@ -0,0 +1,2 @@
13+
+A
14+
+B
15+
diff --git a/file0 b/file0
16+
new file mode 100644
17+
index 0000000..01e79c3
18+
--- /dev/null
19+
+++ b/file0
20+
@@ -0,0 +1,3 @@
21+
+1
22+
+2
23+
+3
24+
diff --git a/file2 b/file2
25+
new file mode 100644
26+
index 0000000..01e79c3
27+
--- /dev/null
28+
+++ b/file2
29+
@@ -0,0 +1,3 @@
30+
+1
31+
+2
32+
+3
33+
$
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$ git diff-tree --pretty=oneline --root --patch-with-stat initial
2+
444ac553ac7612cc88969031b02b3767fb8a353a Initial
3+
---
4+
dir/sub | 2 ++
5+
file0 | 3 +++
6+
file2 | 3 +++
7+
3 files changed, 8 insertions(+), 0 deletions(-)
8+
9+
diff --git a/dir/sub b/dir/sub
10+
new file mode 100644
11+
index 0000000..35d242b
12+
--- /dev/null
13+
+++ b/dir/sub
14+
@@ -0,0 +1,2 @@
15+
+A
16+
+B
17+
diff --git a/file0 b/file0
18+
new file mode 100644
19+
index 0000000..01e79c3
20+
--- /dev/null
21+
+++ b/file0
22+
@@ -0,0 +1,3 @@
23+
+1
24+
+2
25+
+3
26+
diff --git a/file2 b/file2
27+
new file mode 100644
28+
index 0000000..01e79c3
29+
--- /dev/null
30+
+++ b/file2
31+
@@ -0,0 +1,3 @@
32+
+1
33+
+2
34+
+3
35+
$
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
$ git diff-tree --pretty=oneline --root -p initial
2+
444ac553ac7612cc88969031b02b3767fb8a353a Initial
3+
diff --git a/dir/sub b/dir/sub
4+
new file mode 100644
5+
index 0000000..35d242b
6+
--- /dev/null
7+
+++ b/dir/sub
8+
@@ -0,0 +1,2 @@
9+
+A
10+
+B
11+
diff --git a/file0 b/file0
12+
new file mode 100644
13+
index 0000000..01e79c3
14+
--- /dev/null
15+
+++ b/file0
16+
@@ -0,0 +1,3 @@
17+
+1
18+
+2
19+
+3
20+
diff --git a/file2 b/file2
21+
new file mode 100644
22+
index 0000000..01e79c3
23+
--- /dev/null
24+
+++ b/file2
25+
@@ -0,0 +1,3 @@
26+
+1
27+
+2
28+
+3
29+
$
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$ git diff-tree --pretty=oneline --root initial
2+
444ac553ac7612cc88969031b02b3767fb8a353a Initial
3+
:000000 040000 0000000000000000000000000000000000000000 da7a33fa77d8066d6698643940ce5860fe2d7fb3 A dir
4+
:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0
5+
:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2
6+
$

0 commit comments

Comments
 (0)