From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Alexander Gladysh <agladysh@gmail.com>,
Stephan Beyer <s-beyer@gmx.net>,
Daniel Barkalow <barkalow@iabervon.org>
Subject: [PATCH 5/5] revert: add "--strategy" option to choose merge strategy
Date: Wed, 31 Mar 2010 21:22:08 +0200 [thread overview]
Message-ID: <20100331192209.5827.9117.chriscool@tuxfamily.org> (raw)
In-Reply-To: <20100331192014.5827.90637.chriscool@tuxfamily.org>
This patch makes it possible to use a different merge strategy when
cherry-picking. This is usefull mainly for debugging purposes as it
allows to see if some failures are caused by the merge strategy used or
not.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin/revert.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/builtin/revert.c b/builtin/revert.c
index 8219ee2..bbaa937 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -43,6 +43,7 @@ static const char *commit_name;
static int allow_rerere_auto;
static const char *me;
+static const char *strategy;
#define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
@@ -62,6 +63,7 @@ static void parse_args(int argc, const char **argv)
OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
OPT_INTEGER('m', "mainline", &mainline, "parent number"),
OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
+ OPT_STRING(0, "strategy", &strategy, "strategy", "merge strategy"),
OPT_END(),
OPT_END(),
OPT_END(),
@@ -483,8 +485,27 @@ static int revert_or_cherry_pick(int argc, const char **argv)
}
}
- do_recursive_merge(base, next, base_label, next_label,
- head, &msgbuf, defmsg);
+ if (!strategy || !strcmp(strategy, "recursive") || action == REVERT)
+ do_recursive_merge(base, next, base_label, next_label,
+ head, &msgbuf, defmsg);
+ else {
+ int res;
+ struct commit_list *common = NULL;
+ struct commit_list *remotes = NULL;
+ write_message(&msgbuf, defmsg);
+ commit_list_insert(base, &common);
+ commit_list_insert(next, &remotes);
+ res = try_merge_command(strategy, common,
+ sha1_to_hex(head), remotes);
+ free_commit_list(common);
+ free_commit_list(remotes);
+ if (res) {
+ fprintf(stderr, "Automatic %s with strategy %s failed.%s\n",
+ me, strategy, help_msg(commit_name));
+ rerere(allow_rerere_auto);
+ exit(1);
+ }
+ }
/*
*
--
1.7.0.3.454.gd9aeb
prev parent reply other threads:[~2010-03-31 22:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-31 19:22 [PATCH 0/5] add a --strategy option to "git cherry-pick" Christian Couder
2010-03-31 19:22 ` [PATCH 1/5] revert: use strbuf to refactor the code that writes the merge message Christian Couder
2010-03-31 19:22 ` [PATCH 2/5] revert: refactor merge recursive code into its own function Christian Couder
2010-03-31 19:22 ` [PATCH 3/5] merge: refactor code that calls "git merge-STRATEGY" Christian Couder
2010-03-31 19:22 ` [PATCH 4/5] merge: make function try_merge_command non static Christian Couder
2010-03-31 19:22 ` Christian Couder [this message]
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=20100331192209.5827.9117.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=agladysh@gmail.com \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=s-beyer@gmx.net \
/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).