Thread (7 messages) flat view 7 messages, 4 authors, 2016-06-15

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

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:48:57

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:
quoted hunk ↗ jump to hunk
--- 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...

[...]
quoted hunk ↗ jump to hunk
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help