Re: [PATCH] commit -s: allow "(cherry picked " lines in sign-off section
From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:50:03
Jonathan Nieder wrote:
(cherry picked from commit 9d8117e72bf453dd9d85e0cd322ce4a0f8bccbc0) Signed-off-by: Back Porter [off-list ref] The cherry-pick is a step in the line of a patch like any other, so one might prefer to lose the extra newline.
Sigh. s/line/life/ [...]
Signed-off-by: Jonathan Nieder <redacted>
Let's kick off the reviews.
quoted hunk ↗ jump to hunk
--- a/builtin/commit.c +++ b/builtin/commit.c@@ -528,6 +528,8 @@ static int ends_rfc2822_footer(struct strbuf *sb) i++; for (; i < len; i = k) { + static const char cherry_pick[] = "(cherry picked from commit "; +
Better to share this string with builtin/revert.c, no? What would happen when "(cherry picked ..." gets translated? Should only the current language's version be tolerated in the commit footer, or is there something more generic to match for that could take care of wording changes automatically?
quoted hunk ↗ jump to hunk
@@ -535,6 +537,20 @@ static int ends_rfc2822_footer(struct strbuf *sb) if ((buf[k] == ' ' || buf[k] == '\t') && !first) continue; + if (!first && buf[k] == '(' && k + strlen(cherry_pick) < len) { + /* Might be a cherry-pick notice. */ + const char *p = buf + k; + if (!memcmp(p, cherry_pick, strlen(cherry_pick))) { + p = memchr(buf + k, '\n', len - k);
Maybe simpler: p = memchr(... if (!p) return 0; i = p - buf; to reuse the termination condition in the sign-off parser. Presumably the main loop could use memchr() instead of open-coding it as well.