pull: add --[no-]show-forced-updates passthrough

The 'git fetch' command can avoid calculating forced updates, so allow users of 'git pull' to provide that option. This is particularly necessary when the advice to use '--no-show-forced-updates' is given at the end of the command. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Jun 18, 2019 at 13:25 UTC 3883c55138dcfbe2d9a24e3f93a2a4b1d376dde6
1 file changed +7
builtin/pull.c
+7
@@ -128,6 +128,7 @@ static char *opt_update_shallow;
128 static char *opt_refmap;
129 static char *opt_ipv4;
130 static char *opt_ipv6;
131 +static int opt_show_forced_updates = -1;
132
133 static struct option pull_options[] = {
134 /* Shared options */
@@ -240,6 +241,8 @@ static struct option pull_options[] = {
241 OPT_PASSTHRU('6', "ipv6", &opt_ipv6, NULL,
242 N_("use IPv6 addresses only"),
243 PARSE_OPT_NOARG),
244 + OPT_BOOL(0, "show-forced-updates", &opt_show_forced_updates,
245 + N_("check for forced-updates on all updated branches")),
246
247 OPT_END()
248 };
@@ -549,6 +552,10 @@ static int run_fetch(const char *repo, const char **refspecs)
552 argv_array_push(&args, opt_ipv4);
553 if (opt_ipv6)
554 argv_array_push(&args, opt_ipv6);
555 + if (opt_show_forced_updates > 0)
556 + argv_array_push(&args, "--show-forced-updates");
557 + else if (opt_show_forced_updates == 0)
558 + argv_array_push(&args, "--no-show-forced-updates");
559
560 if (repo) {
561 argv_array_push(&args, repo);