Skip to content

Commit 86747c1

Browse files
dzickusrhJunio C Hamano
authored andcommitted
git-mailinfo fixes for patch munging
Don't translate the patch to UTF-8, instead preserve the data as is. This also reverts a test case that was included in the original patch series. Also allow overwriting the authorship and title information we gather from RFC2822 mail headers with additional in-body headers, which was pointed out by Linus. Signed-off-by: Don Zickus <dzickus@redhat.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 5ae917a commit 86747c1

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

builtin-mailinfo.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,14 @@ static char *header[MAX_HDR_PARSED] = {
294294
"From","Subject","Date",
295295
};
296296

297-
static int check_header(char *line, char **hdr_data)
297+
static int check_header(char *line, char **hdr_data, int overwrite)
298298
{
299299
int i;
300300

301301
/* search for the interesting parts */
302302
for (i = 0; header[i]; i++) {
303303
int len = strlen(header[i]);
304-
if (!hdr_data[i] &&
304+
if ((!hdr_data[i] || overwrite) &&
305305
!strncasecmp(line, header[i], len) &&
306306
line[len] == ':' && isspace(line[len + 1])) {
307307
/* Unwrap inline B and Q encoding, and optionally
@@ -614,6 +614,7 @@ static int find_boundary(void)
614614

615615
static int handle_boundary(void)
616616
{
617+
char newline[]="\n";
617618
again:
618619
if (!memcmp(line+content_top->boundary_len, "--", 2)) {
619620
/* we hit an end boundary */
@@ -628,7 +629,7 @@ static int handle_boundary(void)
628629
"can't recover\n");
629630
exit(1);
630631
}
631-
handle_filter("\n");
632+
handle_filter(newline);
632633

633634
/* skip to the next boundary */
634635
if (!find_boundary())
@@ -643,7 +644,7 @@ static int handle_boundary(void)
643644

644645
/* slurp in this section's info */
645646
while (read_one_header_line(line, sizeof(line), fin))
646-
check_header(line, p_hdr_data);
647+
check_header(line, p_hdr_data, 0);
647648

648649
/* eat the blank line after section info */
649650
return (fgets(line, sizeof(line), fin) != NULL);
@@ -699,10 +700,14 @@ static int handle_commit_msg(char *line)
699700
if (!*cp)
700701
return 0;
701702
}
702-
if ((still_looking = check_header(cp, s_hdr_data)) != 0)
703+
if ((still_looking = check_header(cp, s_hdr_data, 0)) != 0)
703704
return 0;
704705
}
705706

707+
/* normalize the log message to UTF-8. */
708+
if (metainfo_charset)
709+
convert_to_utf8(line, charset);
710+
706711
if (patchbreak(line)) {
707712
fclose(cmitmsg);
708713
cmitmsg = NULL;
@@ -767,12 +772,8 @@ static void handle_body(void)
767772
return;
768773
}
769774

770-
/* Unwrap transfer encoding and optionally
771-
* normalize the log message to UTF-8.
772-
*/
775+
/* Unwrap transfer encoding */
773776
decode_transfer_encoding(line);
774-
if (metainfo_charset)
775-
convert_to_utf8(line, charset);
776777

777778
switch (transfer_encoding) {
778779
case TE_BASE64:
@@ -875,7 +876,7 @@ int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
875876

876877
/* process the email header */
877878
while (read_one_header_line(line, sizeof(line), fin))
878-
check_header(line, p_hdr_data);
879+
check_header(line, p_hdr_data, 1);
879880

880881
handle_body();
881882
handle_info();

t/t5100/patch0005

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ diff --git a/git-cvsimport-script b/git-cvsimport-script
6161
push(@old,$fn);
6262

6363
--
64-
David Kågedal
64+
David K�gedal
6565
-
6666
To unsubscribe from this list: send the line "unsubscribe git" in
6767
the body of a message to majordomo@vger.kernel.org

0 commit comments

Comments
 (0)