Skip to content

Commit

Permalink
restrict the patch filtering
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Don Zickus authored and Junio C Hamano committed Mar 13, 2007
1 parent 87ab799 commit f0658cf
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions builtin-mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,39 @@ static int handle_boundary(void)
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;
Expand All @@ -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;
Expand Down

0 comments on commit f0658cf

Please sign in to comment.