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

Re: [PATCH] cherry-pick: Add an option to prepend a string to the commit message

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 12, 2010, 05:58 UTC
Message-ID
<20100612055831.GA2426@burratino>
In-Reply-To
<1276319237-12010-1-git-send-email-bobbypowers@gmail.com>
Bobby Powers wrote:
> This can be useful situations where you have a batch of commits to
> cherry-pick and need to prefix each new commit message with similar
> information
Sounds reasonable.
Cc-ing Christian who is closer to an area expert.
> (such as the subversion revision, when used in conjunction
> with git-svn).
Could you give an example?  I am imagining
  git cherry-pick --prepend='r3815: ' HEAD..svn/Trunk
but I haven’t figured out the context.
The patch itself is clean.  Two tiny nitpicks:
Show 11 quoted lines
> --- a/builtin/revert.c
> +++ b/builtin/revert.c
> @@ -64,7 +65,7 @@ static void parse_args(int argc, const char **argv)
>  		OPT_INTEGER('m', "mainline", &mainline, "parent number"),
>  		OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
>  		OPT_STRING(0, "strategy", &strategy, "strategy", "merge strategy"),
> -		OPT_END(),
> +		OPT_STRING(0, "prepend", &prepend, "message", "string to prepend to the commit message"),
>  		OPT_END(),
>  		OPT_END(),
>  	};
This adds an option to cherry-pick and revert...
[...]
Show 10 quoted lines
> @@ -482,6 +485,9 @@ static int revert_or_cherry_pick(int argc, const char **argv)
>  		next = commit;
>  		next_label = msg.label;
>  		set_author_ident_env(msg.message);
> +		if (prepend) {
> +			strbuf_addstr(&msgbuf, prepend);
> +		}
>  		add_message_to_msg(&msgbuf, msg.message);
>  		if (no_replay) {
>  			strbuf_addstr(&msgbuf, "(cherry picked from commit ");
... and implements it only for cherry-pick (with unnecessary braces).

I would be interested to hear from those who might know whether something generic like the applypatch-msg hook could work (which is not to say a convenient command-line option would not be handy to have in addition to that.)

Jonathan
Previous: Bobby PowersNext: Junio C Hamano
Message 2 of 9 in “cherry-pick: Add an option to prepend a string to the commit message”
  1. cherry-pick: Add an option to prepend a string to the commit messageBobby Powers, Jun 12, 2010
  2. Jonathan NiederJun 12, 2010
  3. Junio C HamanoJun 12, 2010
  4. Jeff KingJun 12, 2010
  5. Bobby PowersJun 12, 2010
  6. Jonathan NiederJun 12, 2010
  7. Jeff KingJun 12, 2010
  8. Junio C HamanoJun 14, 2010
  9. Junio C HamanoJun 14, 2010

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.