pull: pass git-merge's options to git-merge

Specify git-merge's options in the option list, and pass any specified options to git-merge. These options are: * -n, --stat, --summary: since d8abe14 (merge, pull: introduce '--(no-)stat' option, 2008-04-06) * --log: since efb779f (merge, pull: add '--(no-)log' command line option, 2008-04-06) * --squash: since 7d0c688 (git-merge --squash, 2006-06-23) * --commit: since 5072a32 (Teach git-pull about --[no-]ff, --no-squash and --commit, 2007-10-29) * --edit: since 8580830 ("git pull" doesn't know "--edit", 2012-02-11) * --ff, --ff-only: since 5072a32 (Teach git-pull about --[no-]ff, --no-squash and --commit, 2007-10-29) * --verify-signatures: since efed002 (merge/pull: verify GPG signatures of commits being merged, 2013-03-31) * -s, --strategy: since 60fb5b2 (Use git-merge in git-pull (second try)., 2005-09-25) * -X, --strategy-option: since ee2c795 (Teach git-pull to pass -X<option> to git-merge, 2009-11-25) * -S, --gpg-sign: since ea230d8 (pull: add the --gpg-sign option., 2014-02-10) Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Paul Tan committed Jun 14, 2015 at 16:41 UTC 11b6d1780173727b5ecb82428cf49e5788b2985a
1 file changed +75
builtin/pull.c
+75
@@ -20,6 +20,18 @@ static const char * const pull_usage[] = {
20 static int opt_verbosity;
21 static char *opt_progress;
22
23 +/* Options passed to git-merge */
24 +static char *opt_diffstat;
25 +static char *opt_log;
26 +static char *opt_squash;
27 +static char *opt_commit;
28 +static char *opt_edit;
29 +static char *opt_ff;
30 +static char *opt_verify_signatures;
31 +static struct argv_array opt_strategies = ARGV_ARRAY_INIT;
32 +static struct argv_array opt_strategy_opts = ARGV_ARRAY_INIT;
33 +static char *opt_gpg_sign;
34 +
35 static struct option pull_options[] = {
36 /* Shared options */
37 OPT__VERBOSITY(&opt_verbosity),
@@ -27,6 +39,49 @@ static struct option pull_options[] = {
39 N_("force progress reporting"),
40 PARSE_OPT_NOARG),
41
42 + /* Options passed to git-merge */
43 + OPT_GROUP(N_("Options related to merging")),
44 + OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL,
45 + N_("do not show a diffstat at the end of the merge"),
46 + PARSE_OPT_NOARG | PARSE_OPT_NONEG),
47 + OPT_PASSTHRU(0, "stat", &opt_diffstat, NULL,
48 + N_("show a diffstat at the end of the merge"),
49 + PARSE_OPT_NOARG),
50 + OPT_PASSTHRU(0, "summary", &opt_diffstat, NULL,
51 + N_("(synonym to --stat)"),
52 + PARSE_OPT_NOARG | PARSE_OPT_HIDDEN),
53 + OPT_PASSTHRU(0, "log", &opt_log, N_("n"),
54 + N_("add (at most <n>) entries from shortlog to merge commit message"),
55 + PARSE_OPT_OPTARG),
56 + OPT_PASSTHRU(0, "squash", &opt_squash, NULL,
57 + N_("create a single commit instead of doing a merge"),
58 + PARSE_OPT_NOARG),
59 + OPT_PASSTHRU(0, "commit", &opt_commit, NULL,
60 + N_("perform a commit if the merge succeeds (default)"),
61 + PARSE_OPT_NOARG),
62 + OPT_PASSTHRU(0, "edit", &opt_edit, NULL,
63 + N_("edit message before committing"),
64 + PARSE_OPT_NOARG),
65 + OPT_PASSTHRU(0, "ff", &opt_ff, NULL,
66 + N_("allow fast-forward"),
67 + PARSE_OPT_NOARG),
68 + OPT_PASSTHRU(0, "ff-only", &opt_ff, NULL,
69 + N_("abort if fast-forward is not possible"),
70 + PARSE_OPT_NOARG | PARSE_OPT_NONEG),
71 + OPT_PASSTHRU(0, "verify-signatures", &opt_verify_signatures, NULL,
72 + N_("verify that the named commit has a valid GPG signature"),
73 + PARSE_OPT_NOARG),
74 + OPT_PASSTHRU_ARGV('s', "strategy", &opt_strategies, N_("strategy"),
75 + N_("merge strategy to use"),
76 + 0),
77 + OPT_PASSTHRU_ARGV('X', "strategy-option", &opt_strategy_opts,
78 + N_("option=value"),
79 + N_("option for selected merge strategy"),
80 + 0),
81 + OPT_PASSTHRU('S', "gpg-sign", &opt_gpg_sign, N_("key-id"),
82 + N_("GPG sign commit"),
83 + PARSE_OPT_OPTARG),
84 +
85 OPT_END()
86 };
87
@@ -101,6 +156,26 @@ static int run_merge(void)
156 if (opt_progress)
157 argv_array_push(&args, opt_progress);
158
159 + /* Options passed to git-merge */
160 + if (opt_diffstat)
161 + argv_array_push(&args, opt_diffstat);
162 + if (opt_log)
163 + argv_array_push(&args, opt_log);
164 + if (opt_squash)
165 + argv_array_push(&args, opt_squash);
166 + if (opt_commit)
167 + argv_array_push(&args, opt_commit);
168 + if (opt_edit)
169 + argv_array_push(&args, opt_edit);
170 + if (opt_ff)
171 + argv_array_push(&args, opt_ff);
172 + if (opt_verify_signatures)
173 + argv_array_push(&args, opt_verify_signatures);
174 + argv_array_pushv(&args, opt_strategies.argv);
175 + argv_array_pushv(&args, opt_strategy_opts.argv);
176 + if (opt_gpg_sign)
177 + argv_array_push(&args, opt_gpg_sign);
178 +
179 argv_array_push(&args, "FETCH_HEAD");
180 ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
181 argv_array_clear(&args);