Skip to content

Commit d410e43

Browse files
author
Junio C Hamano
committed
t4013: add format-patch tests.
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 47979d5 commit d410e43

7 files changed

+581
-1
lines changed

t/t4013-diff-various.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ test_expect_success setup '
8585
+*+ [initial] Initial
8686
EOF
8787

88+
V=`git version | sed -e 's/^git version //'`
8889
while read cmd
8990
do
9091
case "$cmd" in
@@ -99,7 +100,7 @@ do
99100
test_expect_success "git $cmd" '
100101
{
101102
echo "\$ git $cmd"
102-
git $cmd
103+
git $cmd | sed -e "s/$V/g-i-t--v-e-r-s-i-o-n/"
103104
echo "\$"
104105
} >"$actual" &&
105106
if test -f "$expect"
@@ -219,6 +220,13 @@ show --patch-with-stat side
219220
show --patch-with-raw side
220221
show --patch-with-stat --summary side
221222
223+
format-patch --stdout initial..side
224+
format-patch --stdout initial..master^
225+
format-patch --stdout initial..master
226+
format-patch --attach --stdout initial..side
227+
format-patch --attach --stdout initial..master^
228+
format-patch --attach --stdout initial..master
229+
222230
EOF
223231

224232
test_done
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
$ git format-patch --attach --stdout initial..master
2+
From 7952a93e09bf565b5592766a438b40cd81f4846f Mon Sep 17 00:00:00 2001
3+
From: A U Thor <author@example.com>
4+
Date: Mon, 26 Jun 2006 00:01:00 +0000
5+
Subject: [PATCH] Second
6+
MIME-Version: 1.0
7+
Content-Type: multipart/mixed;
8+
boundary="------------g-i-t--v-e-r-s-i-o-n"
9+
10+
This is a multi-part message in MIME format.
11+
--------------g-i-t--v-e-r-s-i-o-n
12+
Content-Type: text/plain; charset=UTF-8; format=fixed
13+
Content-Transfer-Encoding: 8bit
14+
---
15+
dir/sub | 2 ++
16+
file0 | 3 +++
17+
file2 | 3 ---
18+
3 files changed, 5 insertions(+), 3 deletions(-)
19+
--------------g-i-t--v-e-r-s-i-o-n
20+
Content-Type: text/x-patch;
21+
name="7952a93e09bf565b5592766a438b40cd81f4846f.diff"
22+
Content-Transfer-Encoding: 8bit
23+
Content-Disposition: inline;
24+
filename="7952a93e09bf565b5592766a438b40cd81f4846f.diff"
25+
26+
diff --git a/dir/sub b/dir/sub
27+
index 35d242b..8422d40 100644
28+
--- a/dir/sub
29+
+++ b/dir/sub
30+
@@ -1,2 +1,4 @@
31+
A
32+
B
33+
+C
34+
+D
35+
diff --git a/file0 b/file0
36+
index 01e79c3..b414108 100644
37+
--- a/file0
38+
+++ b/file0
39+
@@ -1,3 +1,6 @@
40+
1
41+
2
42+
3
43+
+4
44+
+5
45+
+6
46+
diff --git a/file2 b/file2
47+
deleted file mode 100644
48+
index 01e79c3..0000000
49+
--- a/file2
50+
+++ /dev/null
51+
@@ -1,3 +0,0 @@
52+
-1
53+
-2
54+
-3
55+
56+
--------------g-i-t--v-e-r-s-i-o-n--
57+
58+
59+
60+
From 889b315013ef9f2e2f90aa0b054b267c8a557847 Mon Sep 17 00:00:00 2001
61+
From: A U Thor <author@example.com>
62+
Date: Mon, 26 Jun 2006 00:02:00 +0000
63+
Subject: [PATCH] Third
64+
MIME-Version: 1.0
65+
Content-Type: multipart/mixed;
66+
boundary="------------g-i-t--v-e-r-s-i-o-n"
67+
68+
This is a multi-part message in MIME format.
69+
--------------g-i-t--v-e-r-s-i-o-n
70+
Content-Type: text/plain; charset=UTF-8; format=fixed
71+
Content-Transfer-Encoding: 8bit
72+
---
73+
dir/sub | 2 ++
74+
file1 | 3 +++
75+
2 files changed, 5 insertions(+), 0 deletions(-)
76+
--------------g-i-t--v-e-r-s-i-o-n
77+
Content-Type: text/x-patch;
78+
name="889b315013ef9f2e2f90aa0b054b267c8a557847.diff"
79+
Content-Transfer-Encoding: 8bit
80+
Content-Disposition: inline;
81+
filename="889b315013ef9f2e2f90aa0b054b267c8a557847.diff"
82+
83+
diff --git a/dir/sub b/dir/sub
84+
index 8422d40..cead32e 100644
85+
--- a/dir/sub
86+
+++ b/dir/sub
87+
@@ -2,3 +2,5 @@ A
88+
B
89+
C
90+
D
91+
+E
92+
+F
93+
diff --git a/file1 b/file1
94+
new file mode 100644
95+
index 0000000..b1e6722
96+
--- /dev/null
97+
+++ b/file1
98+
@@ -0,0 +1,3 @@
99+
+A
100+
+B
101+
+C
102+
103+
--------------g-i-t--v-e-r-s-i-o-n--
104+
105+
106+
107+
From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001
108+
From: A U Thor <author@example.com>
109+
Date: Mon, 26 Jun 2006 00:03:00 +0000
110+
Subject: [PATCH] Side
111+
MIME-Version: 1.0
112+
Content-Type: multipart/mixed;
113+
boundary="------------g-i-t--v-e-r-s-i-o-n"
114+
115+
This is a multi-part message in MIME format.
116+
--------------g-i-t--v-e-r-s-i-o-n
117+
Content-Type: text/plain; charset=UTF-8; format=fixed
118+
Content-Transfer-Encoding: 8bit
119+
---
120+
dir/sub | 2 ++
121+
file0 | 3 +++
122+
file3 | 4 ++++
123+
3 files changed, 9 insertions(+), 0 deletions(-)
124+
--------------g-i-t--v-e-r-s-i-o-n
125+
Content-Type: text/x-patch;
126+
name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
127+
Content-Transfer-Encoding: 8bit
128+
Content-Disposition: inline;
129+
filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
130+
131+
diff --git a/dir/sub b/dir/sub
132+
index 35d242b..7289e35 100644
133+
--- a/dir/sub
134+
+++ b/dir/sub
135+
@@ -1,2 +1,4 @@
136+
A
137+
B
138+
+1
139+
+2
140+
diff --git a/file0 b/file0
141+
index 01e79c3..f4615da 100644
142+
--- a/file0
143+
+++ b/file0
144+
@@ -1,3 +1,6 @@
145+
1
146+
2
147+
3
148+
+A
149+
+B
150+
+C
151+
diff --git a/file3 b/file3
152+
new file mode 100644
153+
index 0000000..7289e35
154+
--- /dev/null
155+
+++ b/file3
156+
@@ -0,0 +1,4 @@
157+
+A
158+
+B
159+
+1
160+
+2
161+
162+
--------------g-i-t--v-e-r-s-i-o-n--
163+
164+
165+
$
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
$ git format-patch --attach --stdout initial..master^
2+
From 7952a93e09bf565b5592766a438b40cd81f4846f Mon Sep 17 00:00:00 2001
3+
From: A U Thor <author@example.com>
4+
Date: Mon, 26 Jun 2006 00:01:00 +0000
5+
Subject: [PATCH] Second
6+
MIME-Version: 1.0
7+
Content-Type: multipart/mixed;
8+
boundary="------------g-i-t--v-e-r-s-i-o-n"
9+
10+
This is a multi-part message in MIME format.
11+
--------------g-i-t--v-e-r-s-i-o-n
12+
Content-Type: text/plain; charset=UTF-8; format=fixed
13+
Content-Transfer-Encoding: 8bit
14+
---
15+
dir/sub | 2 ++
16+
file0 | 3 +++
17+
file2 | 3 ---
18+
3 files changed, 5 insertions(+), 3 deletions(-)
19+
--------------g-i-t--v-e-r-s-i-o-n
20+
Content-Type: text/x-patch;
21+
name="7952a93e09bf565b5592766a438b40cd81f4846f.diff"
22+
Content-Transfer-Encoding: 8bit
23+
Content-Disposition: inline;
24+
filename="7952a93e09bf565b5592766a438b40cd81f4846f.diff"
25+
26+
diff --git a/dir/sub b/dir/sub
27+
index 35d242b..8422d40 100644
28+
--- a/dir/sub
29+
+++ b/dir/sub
30+
@@ -1,2 +1,4 @@
31+
A
32+
B
33+
+C
34+
+D
35+
diff --git a/file0 b/file0
36+
index 01e79c3..b414108 100644
37+
--- a/file0
38+
+++ b/file0
39+
@@ -1,3 +1,6 @@
40+
1
41+
2
42+
3
43+
+4
44+
+5
45+
+6
46+
diff --git a/file2 b/file2
47+
deleted file mode 100644
48+
index 01e79c3..0000000
49+
--- a/file2
50+
+++ /dev/null
51+
@@ -1,3 +0,0 @@
52+
-1
53+
-2
54+
-3
55+
56+
--------------g-i-t--v-e-r-s-i-o-n--
57+
58+
59+
60+
From 889b315013ef9f2e2f90aa0b054b267c8a557847 Mon Sep 17 00:00:00 2001
61+
From: A U Thor <author@example.com>
62+
Date: Mon, 26 Jun 2006 00:02:00 +0000
63+
Subject: [PATCH] Third
64+
MIME-Version: 1.0
65+
Content-Type: multipart/mixed;
66+
boundary="------------g-i-t--v-e-r-s-i-o-n"
67+
68+
This is a multi-part message in MIME format.
69+
--------------g-i-t--v-e-r-s-i-o-n
70+
Content-Type: text/plain; charset=UTF-8; format=fixed
71+
Content-Transfer-Encoding: 8bit
72+
---
73+
dir/sub | 2 ++
74+
file1 | 3 +++
75+
2 files changed, 5 insertions(+), 0 deletions(-)
76+
--------------g-i-t--v-e-r-s-i-o-n
77+
Content-Type: text/x-patch;
78+
name="889b315013ef9f2e2f90aa0b054b267c8a557847.diff"
79+
Content-Transfer-Encoding: 8bit
80+
Content-Disposition: inline;
81+
filename="889b315013ef9f2e2f90aa0b054b267c8a557847.diff"
82+
83+
diff --git a/dir/sub b/dir/sub
84+
index 8422d40..cead32e 100644
85+
--- a/dir/sub
86+
+++ b/dir/sub
87+
@@ -2,3 +2,5 @@ A
88+
B
89+
C
90+
D
91+
+E
92+
+F
93+
diff --git a/file1 b/file1
94+
new file mode 100644
95+
index 0000000..b1e6722
96+
--- /dev/null
97+
+++ b/file1
98+
@@ -0,0 +1,3 @@
99+
+A
100+
+B
101+
+C
102+
103+
--------------g-i-t--v-e-r-s-i-o-n--
104+
105+
106+
$
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
$ git format-patch --attach --stdout initial..side
2+
From c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Mon Sep 17 00:00:00 2001
3+
From: A U Thor <author@example.com>
4+
Date: Mon, 26 Jun 2006 00:03:00 +0000
5+
Subject: [PATCH] Side
6+
MIME-Version: 1.0
7+
Content-Type: multipart/mixed;
8+
boundary="------------g-i-t--v-e-r-s-i-o-n"
9+
10+
This is a multi-part message in MIME format.
11+
--------------g-i-t--v-e-r-s-i-o-n
12+
Content-Type: text/plain; charset=UTF-8; format=fixed
13+
Content-Transfer-Encoding: 8bit
14+
---
15+
dir/sub | 2 ++
16+
file0 | 3 +++
17+
file3 | 4 ++++
18+
3 files changed, 9 insertions(+), 0 deletions(-)
19+
--------------g-i-t--v-e-r-s-i-o-n
20+
Content-Type: text/x-patch;
21+
name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
22+
Content-Transfer-Encoding: 8bit
23+
Content-Disposition: inline;
24+
filename="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
25+
26+
diff --git a/dir/sub b/dir/sub
27+
index 35d242b..7289e35 100644
28+
--- a/dir/sub
29+
+++ b/dir/sub
30+
@@ -1,2 +1,4 @@
31+
A
32+
B
33+
+1
34+
+2
35+
diff --git a/file0 b/file0
36+
index 01e79c3..f4615da 100644
37+
--- a/file0
38+
+++ b/file0
39+
@@ -1,3 +1,6 @@
40+
1
41+
2
42+
3
43+
+A
44+
+B
45+
+C
46+
diff --git a/file3 b/file3
47+
new file mode 100644
48+
index 0000000..7289e35
49+
--- /dev/null
50+
+++ b/file3
51+
@@ -0,0 +1,4 @@
52+
+A
53+
+B
54+
+1
55+
+2
56+
57+
--------------g-i-t--v-e-r-s-i-o-n--
58+
59+
60+
$

0 commit comments

Comments
 (0)