summaryrefslogtreecommitdiff
path: root/builtin-mailinfo.c
diff options
context:
space:
mode:
authorDon Zickus <dzickus@redhat.com>2007-03-12 19:52:06 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-03-13 06:33:41 (GMT)
commitf0658cf2106074b2465a5de0e20f459f966a9e18 (patch)
treed3dec104dcda8b39a065ed1361405b894c0d71af /builtin-mailinfo.c
parent87ab799234639c26ea10de74782fa511cb3ca606 (diff)
downloadgit-f0658cf2106074b2465a5de0e20f459f966a9e18.zip
git-f0658cf2106074b2465a5de0e20f459f966a9e18.tar.gz
git-f0658cf2106074b2465a5de0e20f459f966a9e18.tar.bz2
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 <dzickus@redhat.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-mailinfo.c')
-rw-r--r--builtin-mailinfo.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 3f5cb87..d94578c 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;
+
+ /*
+ * "--- <filename>" starts patches without headers
+ * "---<sp>*" 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;