@matheusbsbs / matheus-bagliano / commits / f0658cf210
Fork 0

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>

Don Zickus committed Mar 12, 2007 at 15:52 UTC f0658cf2106074b2465a5de0e20f459f966a9e18
1 file changed +34 -3
builtin-mailinfo.c
+34 -3
@@ -649,6 +649,39 @@ again:
649 return (fgets(line, sizeof(line), fin) != NULL);
650 }
651
652 +static inline int patchbreak(const char *line)
653 +{
654 + /* Beginning of a "diff -" header? */
655 + if (!memcmp("diff -", line, 6))
656 + return 1;
657 +
658 + /* CVS "Index: " line? */
659 + if (!memcmp("Index: ", line, 7))
660 + return 1;
661 +
662 + /*
663 + * "--- <filename>" starts patches without headers
664 + * "---<sp>*" is a manual separator
665 + */
666 + if (!memcmp("---", line, 3)) {
667 + line += 3;
668 + /* space followed by a filename? */
669 + if (line[0] == ' ' && !isspace(line[1]))
670 + return 1;
671 + /* Just whitespace? */
672 + for (;;) {
673 + unsigned char c = *line++;
674 + if (c == '\n')
675 + return 1;
676 + if (!isspace(c))
677 + break;
678 + }
679 + return 0;
680 + }
681 + return 0;
682 +}
683 +
684 +
685 static int handle_commit_msg(char *line)
686 {
687 static int still_looking = 1;
@@ -670,9 +703,7 @@ static int handle_commit_msg(char *line)
703 return 0;
704 }
705
673 - if (!memcmp("diff -", line, 6) ||
674 - !memcmp("---", line, 3) ||
675 - !memcmp("Index: ", line, 7)) {
706 + if (patchbreak(line)) {
707 fclose(cmitmsg);
708 cmitmsg = NULL;
709 return 1;