Re: [PATCH 3/5] restrict the patch filtering

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Tue, 6 Mar 2007, Don Zickus wrote:
>
> 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.

Ack. I think this is better than what we have now. My only question is 
whether we should allow arbitrary whitespace after the "---", ie all of 
space/tab/newline. Your patch just does space/newline (and only _one_ 
space).

I think the space-only is probably fine - we don't allow tabs there in 
diffs, and the only reason I mention whitespace is that in an editor it's 
actually really hard to see spaces at the ends of lines, so I think it's 
bad form to behave differently for

	"---\n"

than for

	"--- \t \n"

when they both *look* the same in an editor.

> Signed-off-by: Don Zickus <dzickus@xxxxxxxxxx>
Acked-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

Although I'd be even happier with something like

	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;
	}

which is totally untested, of course.

		Linus
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]