mailinfo: re-fix MIME multipart boundary parsing
[git/dscho.git] / t / t5100 / sample.mbox
blob4bf7947b418963e9b15e393fc738e515b3d2141d
1     
2         
3     
4 From nobody Mon Sep 17 00:00:00 2001
5 From: A U Thor <a.u.thor@example.com>
6 Date: Fri, 9 Jun 2006 00:44:16 -0700
7 Subject: [PATCH] a commit.
9 Here is a patch from A U Thor.
11 ---
12  foo |    2 +-
13  1 files changed, 1 insertions(+), 1 deletions(-)
15 diff --git a/foo b/foo
16 index 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 -- 
23 1.4.0.g6f2b
25 From nobody Mon Sep 17 00:00:00 2001
26 From: A U Thor <a.u.thor@example.com>
27 Date: Fri, 9 Jun 2006 00:44:16 -0700
28 Subject: [PATCH] another patch
30 Here is a patch from A U Thor.  This addresses the issue raised in the
31 message:
33 From: Nit Picker <nit.picker@example.net>
34 Subject: foo is too old
35 Message-Id: <nitpicker.12121212@example.net>
37 Hopefully this would fix the problem stated there.
40 I have included an extra blank line above, but it does not have to be
41 stripped away here, along with the                                 
42 whitespaces at the end of the above line.  They are expected to be squashed
43 when the message is made into a commit log by stripspace,
44 Also, there are three blank lines after this paragraph,
45 two truly blank and another full of spaces in between.
47             
49 Hope this helps.
51 ---
52  foo |    2 +-
53  1 files changed, 1 insertions(+), 1 deletions(-)
55 diff --git a/foo b/foo
56 index 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 -- 
63 1.4.0.g6f2b
65 From nobody Mon Sep 17 00:00:00 2001
66 From: Junio C Hamano <junio@kernel.org>
67 Date: Fri, 9 Jun 2006 00:44:16 -0700
68 Subject: re: [PATCH] another patch
70 From: A U Thor <a.u.thor@example.com>
71 Subject: [PATCH] third patch
73 Here is a patch from A U Thor.  This addresses the issue raised in the
74 message:
76 From: Nit Picker <nit.picker@example.net>
77 Subject: foo is too old
78 Message-Id: <nitpicker.12121212@example.net>
80 Hopefully this would fix the problem stated there.
82 ---
83  foo |    2 +-
84  1 files changed, 1 insertions(+), 1 deletions(-)
86 diff --git a/foo b/foo
87 index 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 -- 
94 1.4.0.g6f2b
96 From nobody Sat Aug 27 23:07:49 2005
97 Path: news.gmane.org!not-for-mail
98 Message-ID: <20050721.091036.01119516.yoshfuji@linux-ipv6.org>
99 From: YOSHIFUJI Hideaki / =?iso-2022-jp?B?GyRCNUhGIzFRTEAbKEI=?= 
100         <yoshfuji@linux-ipv6.org>
101 Newsgroups: gmane.comp.version-control.git
102 Subject: [PATCH 1/2] GIT: Try all addresses for given remote name
103 Date: Thu, 21 Jul 2005 09:10:36 -0400 (EDT)
104 Lines: 99
105 Organization: USAGI/WIDE Project
106 Approved: news@gmane.org
107 NNTP-Posting-Host: main.gmane.org
108 Mime-Version: 1.0
109 Content-Type: Text/Plain; charset=us-ascii
110 Content-Transfer-Encoding: 7bit
111 X-Trace: sea.gmane.org 1121951434 29350 80.91.229.2 (21 Jul 2005 13:10:34 GMT)
112 X-Complaints-To: usenet@sea.gmane.org
113 NNTP-Posting-Date: Thu, 21 Jul 2005 13:10:34 +0000 (UTC)
115 Hello.
117 Try all addresses for given remote name until it succeeds.
118 Also supports IPv6.
120 Signed-of-by: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
122 diff --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);
129 -static void lookup_host(const char *host, struct sockaddr *in)
131 -       struct addrinfo *res;
132 -       int ret;
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);
140 +#define STR_(s)        # s
141 +#define STR(s) STR_(s)
143  static int git_tcp_connect(int fd[2], const char *prog, char *host, char *path)
145 -       struct sockaddr addr;
146 -       int port = DEFAULT_GIT_PORT, sockfd;
147 -       char *colon;
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;
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, ':');
174 +       if (colon)
175 +               port = colon + 1;
177 +       memset(&hints, 0, sizeof(hints));
178 +       hints.ai_socktype = SOCK_STREAM;
179 +       hints.ai_protocol = IPPROTO_TCP;
181 +       gai = getaddrinfo(host, port, &hints, &ai);
182 +       if (gai)
183 +               die("Unable to look up %s (%s)", host, gai_strerror(gai));
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         }
197 -       lookup_host(host, &addr);
198 -       ((struct sockaddr_in *)&addr)->sin_port = htons(port);
199 +       freeaddrinfo(ai0);
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));
207         fd[0] = sockfd;
208         fd[1] = sockfd;
209         packet_write(sockfd, "%s %s\n", prog, path);
211 -- 
212 YOSHIFUJI Hideaki @ USAGI Project  <yoshfuji@linux-ipv6.org>
213 GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA
215 From nobody Sat Aug 27 23:07:49 2005
216 Path: news.gmane.org!not-for-mail
217 Message-ID: <u5tacjjdpxq.fsf@lysator.liu.se>
218 From: =?iso-8859-1?Q?David_K=E5gedal?= <davidk@lysator.liu.se>
219 Newsgroups: gmane.comp.version-control.git
220 Subject: [PATCH] Fixed two bugs in git-cvsimport-script.
221 Date: Mon, 15 Aug 2005 20:18:25 +0200
222 Lines: 83
223 Approved: news@gmane.org
224 NNTP-Posting-Host: main.gmane.org
225 Mime-Version: 1.0
226 Content-Type: text/plain; charset=iso-8859-1
227 Content-Transfer-Encoding: QUOTED-PRINTABLE
228 X-Trace: sea.gmane.org 1124130247 31839 80.91.229.2 (15 Aug 2005 18:24:07 GMT)
229 X-Complaints-To: usenet@sea.gmane.org
230 NNTP-Posting-Date: Mon, 15 Aug 2005 18:24:07 +0000 (UTC)
231 Cc: "Junio C. Hamano" <junkio@cox.net>
232 Original-X-From: git-owner@vger.kernel.org Mon Aug 15 20:24:05 2005
234 The git-cvsimport-script had a copule of small bugs that prevented me
235 from importing a big CVS repository.
237 The first was that it didn't handle removed files with a multi-digit
238 primary revision number.
240 The second was that it was asking the CVS server for "F" messages,
241 although they were not handled.
243 I also updated the documentation for that script to correspond to
244 actual flags.
246 Signed-off-by: David K=E5gedal <davidk@lysator.liu.se>
249  Documentation/git-cvsimport-script.txt |    9 ++++++++-
250  git-cvsimport-script                   |    4 ++--
251  2 files changed, 10 insertions(+), 3 deletions(-)
253 50452f9c0c2df1f04d83a26266ba704b13861632
254 diff --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.
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.
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
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.
276         If you need to pass multiple options, separate them with a comma.
278 @@ -57,6 +61,9 @@ OPTIONS
279  -h::
280         Print a short usage message and exit.
282 +-z <fuzz>::
283 +        Pass the timestamp fuzz factor to cvsps.
285  OUTPUT
286  ------
287  If '-v' is specified, the script reports what it is doing.
288 diff --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");
294         # Trial and error says that this probably is the minimum set
295 -       $self->{'socketo'}->write("Valid-responses ok error Valid-requests Mo=
296 de M Mbinary E F Checked-in Created Updated Merged Removed\n");
297 +       $self->{'socketo'}->write("Valid-responses ok error Valid-requests Mo=
298 de M Mbinary E Checked-in Created Updated Merged Removed\n");
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+)+)\(=
307 DEAD\)\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);
314 --=20
315 David K=E5gedal
317 To unsubscribe from this list: send the line "unsubscribe git" in
318 the body of a message to majordomo@vger.kernel.org
319 More majordomo info at  http://vger.kernel.org/majordomo-info.html
321 From nobody Mon Sep 17 00:00:00 2001
322 From: A U Thor <a.u.thor@example.com>
323 References: <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>
373 Date: Fri, 9 Jun 2006 00:44:16 -0700
374 Subject: [PATCH] a commit.
376 Here is a patch from A U Thor.
379  foo |    2 +-
380  1 files changed, 1 insertions(+), 1 deletions(-)
382 diff --git a/foo b/foo
383 index 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 -- 
390 1.4.0.g6f2b
392 From nobody Mon Sep 17 00:00:00 2001
393 From: A U Thor <a.u.thor@example.com>
394 Date: Fri, 9 Jun 2006 00:44:16 -0700
395 Subject: [PATCH] another patch
397 Here is an empty patch from A U Thor.
399 From nobody Mon Sep 17 00:00:00 2001
400 From: Junio C Hamano <junio@kernel.org>
401 Date: Fri, 9 Jun 2006 00:44:16 -0700
402 Subject: re: [PATCH] another patch
404 From: A U Thor <a.u.thor@example.com>
405 Subject: [PATCH] another patch
406 >Here is an empty patch from A U Thor.
408 Hey you forgot the patch!
410 From nobody Mon Sep 17 00:00:00 2001
411 From: A U Thor <a.u.thor@example.com>
412 Date: Mon, 17 Sep 2001 00:00:00 +0900
413 Mime-Version: 1.0
414 Content-Type: Text/Plain; charset=us-ascii
415 Content-Transfer-Encoding: Quoted-Printable
417 =0A=0AFrom: F U Bar <f.u.bar@example.com>
418 Subject: [PATCH] updates=0A=0AThis is to fix diff-format documentation.
420 diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt
421 index 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:
428 -      GIT_DIFF_OPTS=3D-c git-diff-index -p $(cat .git/HEAD)
429 +      GIT_DIFF_OPTS=3D-c git-diff-index -p HEAD
432  2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
433 From b9704a518e21158433baa2cc2d591fea687967f6 Mon Sep 17 00:00:00 2001
434 From: =?UTF-8?q?Lukas=20Sandstr=C3=B6m?= <lukass@etek.chalmers.se>
435 Date: Thu, 10 Jul 2008 23:41:33 +0200
436 Subject: Re: discussion that lead to this patch
437 MIME-Version: 1.0
438 Content-Type: text/plain; charset=UTF-8
439 Content-Transfer-Encoding: 8bit
441 [PATCH] git-mailinfo: Fix getting the subject from the body
443 "Subject: " isn't in the static array "header", and thus
444 memcmp("Subject: ", header[i], 7) will never match.
446 Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
447 Signed-off-by: Junio C Hamano <gitster@pobox.com>
449  builtin-mailinfo.c |    2 +-
450  1 files changed, 1 insertions(+), 1 deletions(-)
452 diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
453 index 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 -- 
466 1.5.6.2.455.g1efb2
468 From nobody Fri Aug  8 22:24:03 2008
469 Date: Fri, 8 Aug 2008 13:08:37 +0200 (CEST)
470 From: A U Thor <a.u.thor@example.com>
471 Subject: [PATCH 3/3 v2] Xyzzy
472 MIME-Version: 1.0
473 Content-Type: multipart/mixed; boundary="=-=-="
475 --=-=-=
476 Content-Type: text/plain; charset=iso-8859-15
477 Content-Transfer-Encoding: quoted-printable
479 Here comes a commit log message, and
480 its second line is here.
482  builtin-mailinfo.c  |    4 ++--
484 diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
485 index 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);
497                         if (!handle_boundary())
498                                 goto handle_body_out;
499 --=20
500 1.6.0.rc2
502 --=-=-=--