pull: add --[no-]show-forced-updates passthrough
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 18 Jun 2019 20:25:28 +0000 (13:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Jun 2019 16:38:29 +0000 (09:38 -0700)
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>
builtin/pull.c
index 9dd32a115bbbfeedb1c1648348ddd32ccaa9b641..f1eaf6e6edb154417e1b38b4f0cfd9d93ef89130 100644 (file)
@@ -128,6 +128,7 @@ static char *opt_update_shallow;
 static char *opt_refmap;
 static char *opt_ipv4;
 static char *opt_ipv6;
+static int opt_show_forced_updates = -1;
 
 static struct option pull_options[] = {
        /* Shared options */
@@ -240,6 +241,8 @@ static struct option pull_options[] = {
        OPT_PASSTHRU('6',  "ipv6", &opt_ipv6, NULL,
                N_("use IPv6 addresses only"),
                PARSE_OPT_NOARG),
+       OPT_BOOL(0, "show-forced-updates", &opt_show_forced_updates,
+                N_("check for forced-updates on all updated branches")),
 
        OPT_END()
 };
@@ -549,6 +552,10 @@ static int run_fetch(const char *repo, const char **refspecs)
                argv_array_push(&args, opt_ipv4);
        if (opt_ipv6)
                argv_array_push(&args, opt_ipv6);
+       if (opt_show_forced_updates > 0)
+               argv_array_push(&args, "--show-forced-updates");
+       else if (opt_show_forced_updates == 0)
+               argv_array_push(&args, "--no-show-forced-updates");
 
        if (repo) {
                argv_array_push(&args, repo);