diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-02-09 16:41:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-02-09 16:41:16 -0800 |
commit | 06938a37dca9bb19784c1bd41e90c99a7c8f8e5e (patch) | |
tree | 25be5b409d7bba815b9e99abc2ccdb4a0230ed2c /builtin | |
parent | Merge branch 'maint-1.7.0' into maint (diff) | |
parent | cherry-pick/revert: add support for -X/--strategy-option (diff) | |
download | tgif-06938a37dca9bb19784c1bd41e90c99a7c8f8e5e.tar.xz |
Merge branch 'jn/cherry-pick-strategy-option'
* jn/cherry-pick-strategy-option:
cherry-pick/revert: add support for -X/--strategy-option
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/merge.c | 6 | ||||
-rw-r--r-- | builtin/revert.c | 29 |
2 files changed, 26 insertions, 9 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index 42fff387e6..9403747b6a 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -582,7 +582,8 @@ static void write_tree_trivial(unsigned char *sha1) die("git write-tree failed to write a tree"); } -int try_merge_command(const char *strategy, struct commit_list *common, +int try_merge_command(const char *strategy, size_t xopts_nr, + const char **xopts, struct commit_list *common, const char *head_arg, struct commit_list *remotes) { const char **args; @@ -680,7 +681,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, rollback_lock_file(lock); return clean ? 0 : 1; } else { - return try_merge_command(strategy, common, head_arg, remoteheads); + return try_merge_command(strategy, xopts_nr, xopts, + common, head_arg, remoteheads); } } diff --git a/builtin/revert.c b/builtin/revert.c index bb6e9e83b7..dc1b702edc 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -44,7 +44,11 @@ static const char **commit_argv; static int allow_rerere_auto; static const char *me; + +/* Merge strategy. */ static const char *strategy; +static const char **xopts; +static size_t xopts_nr, xopts_alloc; #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION" @@ -55,6 +59,17 @@ static const char * const *revert_or_cherry_pick_usage(void) return action == REVERT ? revert_usage : cherry_pick_usage; } +static int option_parse_x(const struct option *opt, + const char *arg, int unset) +{ + if (unset) + return 0; + + ALLOC_GROW(xopts, xopts_nr + 1, xopts_alloc); + xopts[xopts_nr++] = xstrdup(arg); + return 0; +} + static void parse_args(int argc, const char **argv) { const char * const * usage_str = revert_or_cherry_pick_usage(); @@ -67,6 +82,8 @@ 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_CALLBACK('X', "strategy-option", &xopts, "option", + "option for merge strategy", option_parse_x), OPT_END(), OPT_END(), OPT_END(), @@ -311,18 +328,13 @@ static int do_recursive_merge(struct commit *base, struct commit *next, struct merge_options o; struct tree *result, *next_tree, *base_tree, *head_tree; int clean, index_fd; + const char **xopt; static struct lock_file index_lock; index_fd = hold_locked_index(&index_lock, 1); read_cache(); - /* - * NEEDSWORK: cherry-picking between branches with - * different end-of-line normalization is a pain; - * plumb in an option to set o.renormalize? - * (or better: arbitrary -X options) - */ init_merge_options(&o); o.ancestor = base ? base_label : "(empty tree)"; o.branch1 = "HEAD"; @@ -332,6 +344,9 @@ static int do_recursive_merge(struct commit *base, struct commit *next, next_tree = next ? next->tree : empty_tree(); base_tree = base ? base->tree : empty_tree(); + for (xopt = xopts; xopt != xopts + xopts_nr; xopt++) + parse_merge_opt(&o, *xopt); + clean = merge_trees(&o, head_tree, next_tree, base_tree, &result); @@ -503,7 +518,7 @@ static int do_pick_commit(void) commit_list_insert(base, &common); commit_list_insert(next, &remotes); - res = try_merge_command(strategy, common, + res = try_merge_command(strategy, xopts_nr, xopts, common, sha1_to_hex(head), remotes); free_commit_list(common); free_commit_list(remotes); |