git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] commit -s: allow "(cherry picked " lines in sign-off section

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 16, 2010, 20:40 UTC
Message-ID
<20101116204027.GB27390@burratino>
In-Reply-To
<20101116202556.GA27390@burratino>
Jonathan Nieder wrote:
Show 6 quoted lines
> 	(cherry picked from commit 9d8117e72bf453dd9d85e0cd322ce4a0f8bccbc0)
> 
> 	Signed-off-by: Back Porter <backporter@example.com>
> 
> 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 <jrnieder@gmail.com>
Let's kick off the reviews.
Show 8 quoted lines
> --- 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?

Show 9 quoted lines
> @@ -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.

Previous: Jonathan NiederNext: Junio C Hamano
Message 4 of 13 in “cherry-pick -x: add newline before pick note”
  1. cherry-pick -x: add newline before pick noteMichael J Gruber, Nov 16, 2010
  2. Jeff KingNov 16, 2010
  3. commit -s: allow "(cherry picked " lines in sign-off sectionJonathan Nieder, Nov 16, 2010
  4. Jonathan NiederNov 16, 2010
  5. Junio C HamanoNov 16, 2010
  6. Jonathan NiederNov 16, 2010
  7. Junio C HamanoNov 17, 2010
  8. Jay SoffianNov 17, 2010
  9. Jay SoffianNov 17, 2010
  10. Oswald BuddenhagenMar 8, 2011
  11. Jonathan NiederMar 8, 2011
  12. Oswald BuddenhagenMar 8, 2011
  13. Jonathan NiederMar 8, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.