fetch, remote: properly convey --no-prune options to subprocesses
authorMichael Haggerty <mhagger@alum.mit.edu>
Wed, 30 Oct 2013 05:33:04 +0000 (06:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Oct 2013 21:16:41 +0000 (14:16 -0700)
If --no-prune is passed to one of the following commands:

git fetch --all
git fetch --multiple
git fetch --recurse-submodules
git remote update

then it must also be passed to the "fetch" subprocesses that those
commands use to do their work. Otherwise there might be a fetch.prune
or remote.<name>.prune configuration setting that causes pruning to
occur, contrary to the user's express wish.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
builtin/remote.c
index 1514b908d85b27ab6a6e179f8a71d3786ad19b52..5ddb9af05c107e09c453e2e4464c1075a9afec14 100644 (file)
@@ -936,8 +936,8 @@ static void add_options_to_argv(struct argv_array *argv)
 {
        if (dry_run)
                argv_array_push(argv, "--dry-run");
-       if (prune > 0)
-               argv_array_push(argv, "--prune");
+       if (prune != -1)
+               argv_array_push(argv, prune ? "--prune" : "--no-prune");
        if (update_head_ok)
                argv_array_push(argv, "--update-head-ok");
        if (force)
index bffe2f9f718c799bcd50ff51d495458b8b77b73a..f532f354579dc8af7905295a1f3c499e4c18fe11 100644 (file)
@@ -1371,7 +1371,7 @@ static int get_remote_default(const char *key, const char *value, void *priv)
 
 static int update(int argc, const char **argv)
 {
-       int i, prune = 0;
+       int i, prune = -1;
        struct option options[] = {
                OPT_BOOL('p', "prune", &prune,
                         N_("prune remotes after fetching")),
@@ -1386,8 +1386,8 @@ static int update(int argc, const char **argv)
 
        argv_array_push(&fetch_argv, "fetch");
 
-       if (prune)
-               argv_array_push(&fetch_argv, "--prune");
+       if (prune != -1)
+               argv_array_push(&fetch_argv, prune ? "--prune" : "--no-prune");
        if (verbose)
                argv_array_push(&fetch_argv, "-v");
        argv_array_push(&fetch_argv, "--multiple");