revert: add "--strategy" option to choose merge strategy
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
c674d05273
commit
91e5259896
@ -42,6 +42,7 @@ static const char *commit_name;
|
|||||||
static int allow_rerere_auto;
|
static int allow_rerere_auto;
|
||||||
|
|
||||||
static const char *me;
|
static const char *me;
|
||||||
|
static const char *strategy;
|
||||||
|
|
||||||
#define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
|
#define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ static void parse_args(int argc, const char **argv)
|
|||||||
OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
|
OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
|
||||||
OPT_INTEGER('m', "mainline", &mainline, "parent number"),
|
OPT_INTEGER('m', "mainline", &mainline, "parent number"),
|
||||||
OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
|
OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
|
||||||
|
OPT_STRING(0, "strategy", &strategy, "strategy", "merge strategy"),
|
||||||
OPT_END(),
|
OPT_END(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -444,8 +446,27 @@ static int revert_or_cherry_pick(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
do_recursive_merge(base, next, base_label, next_label,
|
if (!strategy || !strcmp(strategy, "recursive") || action == REVERT)
|
||||||
head, &msgbuf, defmsg);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user