[PATCH] cherry-pick: Add an option to prepend a string to the commit message
From: Bobby Powers <hidden>
Date: 2016-06-15 22:48:57
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
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 (such as the subversion revision, when used in conjunction with git-svn). Signed-off-by: Bobby Powers <redacted> --- Documentation/git-cherry-pick.txt | 7 +++++++ builtin/revert.c | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index d71607a..2526e13 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt@@ -62,6 +62,13 @@ OPTIONS option is used, your index does not have to match the HEAD commit. The cherry-pick is done against the beginning state of your index. + +--prepend:: + Specify a string to prepend to the commit message. 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 (such as the subversion revision, + when used in conjunction with git-svn). + This is useful when cherry-picking more than one commits' effect to your index in a row.
diff --git a/builtin/revert.c b/builtin/revert.c
index 7976b5a..45091ac 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c@@ -44,6 +44,7 @@ static int allow_rerere_auto; static const char *me; static const char *strategy; +static const char *prepend; #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
@@ -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(), };
@@ -392,6 +393,8 @@ static int revert_or_cherry_pick(int argc, const char **argv) die("cherry-pick --ff cannot be used with -x"); if (edit) die("cherry-pick --ff cannot be used with --edit"); + if (prepend) + die("cherry-pick --ff cannot be used with --prepend"); } if (read_cache() < 0)
@@ -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 ");
--
1.7.1.251.g92a7.dirty