git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bobby Powers <bobbypowers@gmail.com>
To: git@vger.kernel.org, gitster@pobox.com, jrnieder@gmail.com
Cc: Bobby Powers <bobbypowers@gmail.com>
Subject: [PATCH] cherry-pick: Add an option to prepend a string to the commit message
Date: Fri, 11 Jun 2010 22:07:17 -0700	[thread overview]
Message-ID: <1276319237-12010-1-git-send-email-bobbypowers@gmail.com> (raw)

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 <bobbypowers@gmail.com>
---
 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

             reply	other threads:[~2010-06-12  5:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-12  5:07 Bobby Powers [this message]
2010-06-12  5:58 ` [PATCH] cherry-pick: Add an option to prepend a string to the commit message Jonathan Nieder
2010-06-12  6:18   ` Junio C Hamano
2010-06-12  6:28   ` Jeff King
2010-06-12  6:43     ` Bobby Powers
2010-06-12  7:18       ` Jonathan Nieder
2010-06-12  8:19         ` Jeff King
2010-06-14  5:33           ` Junio C Hamano
2010-06-14 18:03         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1276319237-12010-1-git-send-email-bobbypowers@gmail.com \
    --to=bobbypowers@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).