Re: [RFC/PATCH] log: add log.firstparent option

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

 



On Fri, Jul 24, 2015 at 08:31:55AM -0700, Junio C Hamano wrote:

> Jeff King <peff@xxxxxxxx> writes:
> 
> > Whoops. Usually I "format-patch -s" and then add any notes while
> > sending. But the wifi at OSCON was so abysmal that instead I wrote the
> > notes directly into the commit message to send the whole thing later.
> > And of course format-patch is not smart enough to know that I meant
> > everything after the "---" as notes. :)
> 
> I think in the cycle we merged Couder's trailer stuff we updated the
> helper functions to locate where the S-o-b should go in an existing
> message and consolidated (or, at least "talked about consolidating")
> them into a single helper.  I do not think we wrote any special case
> for "a line with three-dashes and nothing else on it" when we did
> so, but that function would be the logical place to do so.

Yeah, it nicely has the concept of "ignore this footer". But we would
want it only to kick in when doing emails (where the "---" is
syntactically significant), I would think. So something like the patch
below (no commit message because I'm in an airport right now; I'll add
tests and repost in the next day or two).

diff --git a/log-tree.c b/log-tree.c
index 7b1b57a..8a9c35b 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -688,8 +688,16 @@ void show_log(struct rev_info *opt)
 		ctx.from_ident = &opt->from_ident;
 	pretty_print_commit(&ctx, commit, &msgbuf);
 
-	if (opt->add_signoff)
-		append_signoff(&msgbuf, 0, APPEND_SIGNOFF_DEDUP);
+	if (opt->add_signoff) {
+		int ignore = 0;
+		if (ctx.fmt == CMIT_FMT_EMAIL) {
+			const char *dashes = strstr(msgbuf.buf, "---\n");
+			if (dashes &&
+			    (dashes == msgbuf.buf || dashes[-1] == '\n'))
+				ignore = msgbuf.len - (dashes - msgbuf.buf);
+		}
+		append_signoff(&msgbuf, ignore, APPEND_SIGNOFF_DEDUP);
+	}
 
 	if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
 	    ctx.notes_message && *ctx.notes_message) {
--
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]