From: Don Zickus Date: Mon, 12 Mar 2007 19:52:06 +0000 (-0400) Subject: restrict the patch filtering X-Git-Tag: v1.5.1-rc1~31^2~1 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=f0658cf2106074b2465a5de0e20f459f966a9e18;p=git.git restrict the patch filtering I have come across many emails that use long strings of '-'s as separators for ideas. This patch below limits the separator to only 3 '-', with the intent that long string of '-'s will stay in the commit msg and not in the patch file. Signed-off-by: Don Zickus Acked-by: Linus Torvalds Signed-off-by: Junio C Hamano --- diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index 3f5cb8719..d94578cb4 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -649,6 +649,39 @@ again: return (fgets(line, sizeof(line), fin) != NULL); } +static inline int patchbreak(const char *line) +{ + /* Beginning of a "diff -" header? */ + if (!memcmp("diff -", line, 6)) + return 1; + + /* CVS "Index: " line? */ + if (!memcmp("Index: ", line, 7)) + return 1; + + /* + * "--- " starts patches without headers + * "---*" is a manual separator + */ + if (!memcmp("---", line, 3)) { + line += 3; + /* space followed by a filename? */ + if (line[0] == ' ' && !isspace(line[1])) + return 1; + /* Just whitespace? */ + for (;;) { + unsigned char c = *line++; + if (c == '\n') + return 1; + if (!isspace(c)) + break; + } + return 0; + } + return 0; +} + + static int handle_commit_msg(char *line) { static int still_looking = 1; @@ -670,9 +703,7 @@ static int handle_commit_msg(char *line) return 0; } - if (!memcmp("diff -", line, 6) || - !memcmp("---", line, 3) || - !memcmp("Index: ", line, 7)) { + if (patchbreak(line)) { fclose(cmitmsg); cmitmsg = NULL; return 1;