mailinfo: re-fix MIME multipart boundary parsing
[git/git.git] / t / t5100 / sample.mbox
CommitLineData
f88a545a
SS
1
2
3
4839c0b5
JH
4From nobody Mon Sep 17 00:00:00 2001
5From: A U Thor <a.u.thor@example.com>
6Date: Fri, 9 Jun 2006 00:44:16 -0700
7Subject: [PATCH] a commit.
8
9Here is a patch from A U Thor.
10
11---
12 foo | 2 +-
13 1 files changed, 1 insertions(+), 1 deletions(-)
14
15diff --git a/foo b/foo
16index 9123cdc..918dcf8 100644
17--- a/foo
18+++ b/foo
19@@ -1 +1 @@
20-Fri Jun 9 00:44:04 PDT 2006
21+Fri Jun 9 00:44:13 PDT 2006
22--
231.4.0.g6f2b
24
25From nobody Mon Sep 17 00:00:00 2001
26From: A U Thor <a.u.thor@example.com>
27Date: Fri, 9 Jun 2006 00:44:16 -0700
28Subject: [PATCH] another patch
29
30Here is a patch from A U Thor. This addresses the issue raised in the
31message:
32
33From: Nit Picker <nit.picker@example.net>
34Subject: foo is too old
35Message-Id: <nitpicker.12121212@example.net>
36
37Hopefully this would fix the problem stated there.
38
39
40I have included an extra blank line above, but it does not have to be
41stripped away here, along with the
42whitespaces at the end of the above line. They are expected to be squashed
43when the message is made into a commit log by stripspace,
44Also, there are three blank lines after this paragraph,
45two truly blank and another full of spaces in between.
46
47
48
49Hope this helps.
50
51---
52 foo | 2 +-
53 1 files changed, 1 insertions(+), 1 deletions(-)
54
55diff --git a/foo b/foo
56index 9123cdc..918dcf8 100644
57--- a/foo
58+++ b/foo
59@@ -1 +1 @@
60-Fri Jun 9 00:44:04 PDT 2006
61+Fri Jun 9 00:44:13 PDT 2006
62--
631.4.0.g6f2b
64
65From nobody Mon Sep 17 00:00:00 2001
66From: Junio C Hamano <junio@kernel.org>
67Date: Fri, 9 Jun 2006 00:44:16 -0700
68Subject: re: [PATCH] another patch
69
70From: A U Thor <a.u.thor@example.com>
71Subject: [PATCH] third patch
72
73Here is a patch from A U Thor. This addresses the issue raised in the
74message:
75
76From: Nit Picker <nit.picker@example.net>
77Subject: foo is too old
78Message-Id: <nitpicker.12121212@example.net>
79
80Hopefully this would fix the problem stated there.
81
82---
83 foo | 2 +-
84 1 files changed, 1 insertions(+), 1 deletions(-)
85
86diff --git a/foo b/foo
87index 9123cdc..918dcf8 100644
88--- a/foo
89+++ b/foo
90@@ -1 +1 @@
91-Fri Jun 9 00:44:04 PDT 2006
92+Fri Jun 9 00:44:13 PDT 2006
93--
941.4.0.g6f2b
95
96From nobody Sat Aug 27 23:07:49 2005
97Path: news.gmane.org!not-for-mail
98Message-ID: <20050721.091036.01119516.yoshfuji@linux-ipv6.org>
99From: YOSHIFUJI Hideaki / =?iso-2022-jp?B?GyRCNUhGIzFRTEAbKEI=?=
100 <yoshfuji@linux-ipv6.org>
101Newsgroups: gmane.comp.version-control.git
102Subject: [PATCH 1/2] GIT: Try all addresses for given remote name
103Date: Thu, 21 Jul 2005 09:10:36 -0400 (EDT)
104Lines: 99
105Organization: USAGI/WIDE Project
106Approved: news@gmane.org
107NNTP-Posting-Host: main.gmane.org
108Mime-Version: 1.0
109Content-Type: Text/Plain; charset=us-ascii
110Content-Transfer-Encoding: 7bit
111X-Trace: sea.gmane.org 1121951434 29350 80.91.229.2 (21 Jul 2005 13:10:34 GMT)
112X-Complaints-To: usenet@sea.gmane.org
113NNTP-Posting-Date: Thu, 21 Jul 2005 13:10:34 +0000 (UTC)
114
115Hello.
116
117Try all addresses for given remote name until it succeeds.
118Also supports IPv6.
119
120Signed-of-by: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
121
122diff --git a/connect.c b/connect.c
123--- a/connect.c
124+++ b/connect.c
125@@ -96,42 +96,57 @@ static enum protocol get_protocol(const
126 die("I don't handle protocol '%s'", name);
127 }
128
129-static void lookup_host(const char *host, struct sockaddr *in)
130-{
131- struct addrinfo *res;
132- int ret;
133-
134- ret = getaddrinfo(host, NULL, NULL, &res);
135- if (ret)
136- die("Unable to look up %s (%s)", host, gai_strerror(ret));
137- *in = *res->ai_addr;
138- freeaddrinfo(res);
139-}
140+#define STR_(s) # s
141+#define STR(s) STR_(s)
142
143 static int git_tcp_connect(int fd[2], const char *prog, char *host, char *path)
144 {
145- struct sockaddr addr;
146- int port = DEFAULT_GIT_PORT, sockfd;
147- char *colon;
148-
149- colon = strchr(host, ':');
150- if (colon) {
151- char *end;
152- unsigned long n = strtoul(colon+1, &end, 0);
153- if (colon[1] && !*end) {
154- *colon = 0;
155- port = n;
156+ int sockfd = -1;
157+ char *colon, *end;
158+ char *port = STR(DEFAULT_GIT_PORT);
159+ struct addrinfo hints, *ai0, *ai;
160+ int gai;
161+
162+ if (host[0] == '[') {
163+ end = strchr(host + 1, ']');
164+ if (end) {
165+ *end = 0;
166+ end++;
167+ host++;
168+ } else
169+ end = host;
170+ } else
171+ end = host;
172+ colon = strchr(end, ':');
173+
174+ if (colon)
175+ port = colon + 1;
176+
177+ memset(&hints, 0, sizeof(hints));
178+ hints.ai_socktype = SOCK_STREAM;
179+ hints.ai_protocol = IPPROTO_TCP;
180+
181+ gai = getaddrinfo(host, port, &hints, &ai);
182+ if (gai)
183+ die("Unable to look up %s (%s)", host, gai_strerror(gai));
184+
185+ for (ai0 = ai; ai; ai = ai->ai_next) {
186+ sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
187+ if (sockfd < 0)
188+ continue;
189+ if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) < 0) {
190+ close(sockfd);
191+ sockfd = -1;
192+ continue;
193 }
194+ break;
195 }
196
197- lookup_host(host, &addr);
198- ((struct sockaddr_in *)&addr)->sin_port = htons(port);
199+ freeaddrinfo(ai0);
200
201- sockfd = socket(PF_INET, SOCK_STREAM, IPPROTO_IP);
202 if (sockfd < 0)
203 die("unable to create socket (%s)", strerror(errno));
204- if (connect(sockfd, (void *)&addr, sizeof(addr)) < 0)
205- die("unable to connect (%s)", strerror(errno));
206+
207 fd[0] = sockfd;
208 fd[1] = sockfd;
209 packet_write(sockfd, "%s %s\n", prog, path);
210
211--
212YOSHIFUJI Hideaki @ USAGI Project <yoshfuji@linux-ipv6.org>
213GPG-FP : 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
214
215From nobody Sat Aug 27 23:07:49 2005
216Path: news.gmane.org!not-for-mail
217Message-ID: <u5tacjjdpxq.fsf@lysator.liu.se>
218From: =?iso-8859-1?Q?David_K=E5gedal?= <davidk@lysator.liu.se>
219Newsgroups: gmane.comp.version-control.git
220Subject: [PATCH] Fixed two bugs in git-cvsimport-script.
221Date: Mon, 15 Aug 2005 20:18:25 +0200
222Lines: 83
223Approved: news@gmane.org
224NNTP-Posting-Host: main.gmane.org
225Mime-Version: 1.0
226Content-Type: text/plain; charset=iso-8859-1
227Content-Transfer-Encoding: QUOTED-PRINTABLE
228X-Trace: sea.gmane.org 1124130247 31839 80.91.229.2 (15 Aug 2005 18:24:07 GMT)
229X-Complaints-To: usenet@sea.gmane.org
230NNTP-Posting-Date: Mon, 15 Aug 2005 18:24:07 +0000 (UTC)
231Cc: "Junio C. Hamano" <junkio@cox.net>
232Original-X-From: git-owner@vger.kernel.org Mon Aug 15 20:24:05 2005
233
234The git-cvsimport-script had a copule of small bugs that prevented me
235from importing a big CVS repository.
236
237The first was that it didn't handle removed files with a multi-digit
238primary revision number.
239
240The second was that it was asking the CVS server for "F" messages,
241although they were not handled.
242
243I also updated the documentation for that script to correspond to
244actual flags.
245
246Signed-off-by: David K=E5gedal <davidk@lysator.liu.se>
247---
248
249 Documentation/git-cvsimport-script.txt | 9 ++++++++-
250 git-cvsimport-script | 4 ++--
251 2 files changed, 10 insertions(+), 3 deletions(-)
252
25350452f9c0c2df1f04d83a26266ba704b13861632
254diff --git a/Documentation/git-cvsimport-script.txt b/Documentation/git=
255-cvsimport-script.txt
256--- a/Documentation/git-cvsimport-script.txt
257+++ b/Documentation/git-cvsimport-script.txt
258@@ -29,6 +29,10 @@ OPTIONS
259 currently, only the :local:, :ext: and :pserver: access methods=20
260 are supported.
261=20
262+-C <target-dir>::
263+ The GIT repository to import to. If the directory doesn't
264+ exist, it will be created. Default is the current directory.
265+
266 -i::
267 Import-only: don't perform a checkout after importing. This option
268 ensures the working directory and cache remain untouched and will
269@@ -44,7 +48,7 @@ OPTIONS
270=20
271 -p <options-for-cvsps>::
272 Additional options for cvsps.
273- The options '-x' and '-A' are implicit and should not be used here.
274+ The options '-u' and '-A' are implicit and should not be used here.
275=20
276 If you need to pass multiple options, separate them with a comma.
277=20
278@@ -57,6 +61,9 @@ OPTIONS
279 -h::
280 Print a short usage message and exit.
281=20
282+-z <fuzz>::
283+ Pass the timestamp fuzz factor to cvsps.
284+
285 OUTPUT
286 ------
287 If '-v' is specified, the script reports what it is doing.
288diff --git a/git-cvsimport-script b/git-cvsimport-script
289--- a/git-cvsimport-script
290+++ b/git-cvsimport-script
291@@ -190,7 +190,7 @@ sub conn {
292 $self->{'socketo'}->write("Root $repo\n");
293=20
294 # Trial and error says that this probably is the minimum set
295- $self->{'socketo'}->write("Valid-responses ok error Valid-requests Mo=
296de M Mbinary E F Checked-in Created Updated Merged Removed\n");
297+ $self->{'socketo'}->write("Valid-responses ok error Valid-requests Mo=
298de M Mbinary E Checked-in Created Updated Merged Removed\n");
299=20
300 $self->{'socketo'}->write("valid-requests\n");
301 $self->{'socketo'}->flush();
302@@ -691,7 +691,7 @@ while(<CVS>) {
303 unlink($tmpname);
304 my $mode =3D pmode($cvs->{'mode'});
305 push(@new,[$mode, $sha, $fn]); # may be resurrected!
306- } elsif($state =3D=3D 9 and /^\s+(\S+):\d(?:\.\d+)+->(\d(?:\.\d+)+)\(=
307DEAD\)\s*$/) {
308+ } elsif($state =3D=3D 9 and /^\s+(\S+):\d+(?:\.\d+)+->(\d+(?:\.\d+)+)=
309\(DEAD\)\s*$/) {
310 my $fn =3D $1;
311 $fn =3D~ s#^/+##;
312 push(@old,$fn);
313
314--=20
315David K=E5gedal
316-
317To unsubscribe from this list: send the line "unsubscribe git" in
318the body of a message to majordomo@vger.kernel.org
319More majordomo info at http://vger.kernel.org/majordomo-info.html
320
34fc5cef
LT
321From nobody Mon Sep 17 00:00:00 2001
322From: A U Thor <a.u.thor@example.com>
323References: <Pine.LNX.4.640.0001@woody.linux-foundation.org>
324 <Pine.LNX.4.640.0002@woody.linux-foundation.org>
325 <Pine.LNX.4.640.0003@woody.linux-foundation.org>
326 <Pine.LNX.4.640.0004@woody.linux-foundation.org>
327 <Pine.LNX.4.640.0005@woody.linux-foundation.org>
328 <Pine.LNX.4.640.0006@woody.linux-foundation.org>
329 <Pine.LNX.4.640.0007@woody.linux-foundation.org>
330 <Pine.LNX.4.640.0008@woody.linux-foundation.org>
331 <Pine.LNX.4.640.0009@woody.linux-foundation.org>
332 <Pine.LNX.4.640.0010@woody.linux-foundation.org>
333 <Pine.LNX.4.640.0011@woody.linux-foundation.org>
334 <Pine.LNX.4.640.0012@woody.linux-foundation.org>
335 <Pine.LNX.4.640.0013@woody.linux-foundation.org>
336 <Pine.LNX.4.640.0014@woody.linux-foundation.org>
337 <Pine.LNX.4.640.0015@woody.linux-foundation.org>
338 <Pine.LNX.4.640.0016@woody.linux-foundation.org>
339 <Pine.LNX.4.640.0017@woody.linux-foundation.org>
340 <Pine.LNX.4.640.0018@woody.linux-foundation.org>
341 <Pine.LNX.4.640.0019@woody.linux-foundation.org>
342 <Pine.LNX.4.640.0020@woody.linux-foundation.org>
343 <Pine.LNX.4.640.0021@woody.linux-foundation.org>
344 <Pine.LNX.4.640.0022@woody.linux-foundation.org>
345 <Pine.LNX.4.640.0023@woody.linux-foundation.org>
346 <Pine.LNX.4.640.0024@woody.linux-foundation.org>
347 <Pine.LNX.4.640.0025@woody.linux-foundation.org>
348 <Pine.LNX.4.640.0026@woody.linux-foundation.org>
349 <Pine.LNX.4.640.0027@woody.linux-foundation.org>
350 <Pine.LNX.4.640.0028@woody.linux-foundation.org>
351 <Pine.LNX.4.640.0029@woody.linux-foundation.org>
352 <Pine.LNX.4.640.0030@woody.linux-foundation.org>
353 <Pine.LNX.4.640.0031@woody.linux-foundation.org>
354 <Pine.LNX.4.640.0032@woody.linux-foundation.org>
355 <Pine.LNX.4.640.0033@woody.linux-foundation.org>
356 <Pine.LNX.4.640.0034@woody.linux-foundation.org>
357 <Pine.LNX.4.640.0035@woody.linux-foundation.org>
358 <Pine.LNX.4.640.0036@woody.linux-foundation.org>
359 <Pine.LNX.4.640.0037@woody.linux-foundation.org>
360 <Pine.LNX.4.640.0038@woody.linux-foundation.org>
361 <Pine.LNX.4.640.0039@woody.linux-foundation.org>
362 <Pine.LNX.4.640.0040@woody.linux-foundation.org>
363 <Pine.LNX.4.640.0041@woody.linux-foundation.org>
364 <Pine.LNX.4.640.0042@woody.linux-foundation.org>
365 <Pine.LNX.4.640.0043@woody.linux-foundation.org>
366 <Pine.LNX.4.640.0044@woody.linux-foundation.org>
367 <Pine.LNX.4.640.0045@woody.linux-foundation.org>
368 <Pine.LNX.4.640.0046@woody.linux-foundation.org>
369 <Pine.LNX.4.640.0047@woody.linux-foundation.org>
370 <Pine.LNX.4.640.0048@woody.linux-foundation.org>
371 <Pine.LNX.4.640.0049@woody.linux-foundation.org>
372 <Pine.LNX.4.640.0050@woody.linux-foundation.org>
373Date: Fri, 9 Jun 2006 00:44:16 -0700
374Subject: [PATCH] a commit.
375
376Here is a patch from A U Thor.
377
378---
379 foo | 2 +-
380 1 files changed, 1 insertions(+), 1 deletions(-)
381
382diff --git a/foo b/foo
383index 9123cdc..918dcf8 100644
384--- a/foo
385+++ b/foo
386@@ -1 +1 @@
387-Fri Jun 9 00:44:04 PDT 2006
388+Fri Jun 9 00:44:13 PDT 2006
389--
3901.4.0.g6f2b
391
ae1a7437
DZ
392From nobody Mon Sep 17 00:00:00 2001
393From: A U Thor <a.u.thor@example.com>
394Date: Fri, 9 Jun 2006 00:44:16 -0700
395Subject: [PATCH] another patch
396
397Here is an empty patch from A U Thor.
398
399From nobody Mon Sep 17 00:00:00 2001
400From: Junio C Hamano <junio@kernel.org>
401Date: Fri, 9 Jun 2006 00:44:16 -0700
402Subject: re: [PATCH] another patch
403
404From: A U Thor <a.u.thor@example.com>
405Subject: [PATCH] another patch
406>Here is an empty patch from A U Thor.
407
408Hey you forgot the patch!
409
87f1b884
JS
410From nobody Mon Sep 17 00:00:00 2001
411From: A U Thor <a.u.thor@example.com>
412Date: Mon, 17 Sep 2001 00:00:00 +0900
413Mime-Version: 1.0
414Content-Type: Text/Plain; charset=us-ascii
415Content-Transfer-Encoding: Quoted-Printable
416
417=0A=0AFrom: F U Bar <f.u.bar@example.com>
418Subject: [PATCH] updates=0A=0AThis is to fix diff-format documentation.
419
420diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt
421index b426a14..97756ec 100644
422--- a/Documentation/diff-format.txt
423+++ b/Documentation/diff-format.txt
424@@ -81,7 +81,7 @@ The "diff" formatting options can be customized via the
425 environment variable 'GIT_DIFF_OPTS'. For example, if you
426 prefer context diff:
427=20
428- GIT_DIFF_OPTS=3D-c git-diff-index -p $(cat .git/HEAD)
429+ GIT_DIFF_OPTS=3D-c git-diff-index -p HEAD
430=20
431=20
432 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
e9fe804a
LS
433From b9704a518e21158433baa2cc2d591fea687967f6 Mon Sep 17 00:00:00 2001
434From: =?UTF-8?q?Lukas=20Sandstr=C3=B6m?= <lukass@etek.chalmers.se>
435Date: Thu, 10 Jul 2008 23:41:33 +0200
436Subject: Re: discussion that lead to this patch
437MIME-Version: 1.0
438Content-Type: text/plain; charset=UTF-8
439Content-Transfer-Encoding: 8bit
440
441[PATCH] git-mailinfo: Fix getting the subject from the body
442
443"Subject: " isn't in the static array "header", and thus
444memcmp("Subject: ", header[i], 7) will never match.
445
446Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
447Signed-off-by: Junio C Hamano <gitster@pobox.com>
448---
449 builtin-mailinfo.c | 2 +-
450 1 files changed, 1 insertions(+), 1 deletions(-)
451
452diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
453index 962aa34..2d1520f 100644
454--- a/builtin-mailinfo.c
455+++ b/builtin-mailinfo.c
456@@ -334,7 +334,7 @@ static int check_header(char *line, unsigned linesize, char **hdr_data, int over
457 return 1;
458 if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) {
459 for (i = 0; header[i]; i++) {
460- if (!memcmp("Subject: ", header[i], 9)) {
461+ if (!memcmp("Subject", header[i], 7)) {
462 if (! handle_header(line, hdr_data[i], 0)) {
463 return 1;
464 }
465--
4661.5.6.2.455.g1efb2
467
a9fd1383
JH
468From nobody Fri Aug 8 22:24:03 2008
469Date: Fri, 8 Aug 2008 13:08:37 +0200 (CEST)
470From: A U Thor <a.u.thor@example.com>
471Subject: [PATCH 3/3 v2] Xyzzy
472MIME-Version: 1.0
473Content-Type: multipart/mixed; boundary="=-=-="
474
475--=-=-=
476Content-Type: text/plain; charset=iso-8859-15
477Content-Transfer-Encoding: quoted-printable
478
479Here comes a commit log message, and
480its second line is here.
481---
482 builtin-mailinfo.c | 4 ++--
483
484diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
485index 3e5fe51..aabfe5c 100644
486--- a/builtin-mailinfo.c
487+++ b/builtin-mailinfo.c
488@@ -758,8 +758,8 @@ static void handle_body(void)
489 /* process any boundary lines */
490 if (*content_top && is_multipart_boundary(&line)) {
491 /* flush any leftover */
492- if (line.len)
493- handle_filter(&line);
494+ if (prev.len)
495+ handle_filter(&prev);
496=20
497 if (!handle_boundary())
498 goto handle_body_out;
499--=20
5001.6.0.rc2
501
502--=-=-=--
289796dd 503