From: "Kirill A. Korinskiy" <catap@xxxxxxxx> Basic idea is a make behavior `git remote update --prune' to `git remote update' as default to specify or all remotes repos. Signed-off-by: Kirill A. Korinskiy <catap@xxxxxxxx> --- builtin/fetch.c | 4 +++- builtin/remote.c | 13 +++++++++++++ remote.c | 2 ++ remote.h | 2 ++ t/t5505-remote.sh | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+), 1 deletion(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index d784b2e..cf23218 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -769,7 +769,7 @@ static int do_fetch(struct transport *transport, free_refs(ref_map); retcode = 1; goto cleanup; - } + } if (prune) { /* If --tags was specified, pretend the user gave us the canonical tags refspec */ if (tags == TAGS_SET) { @@ -983,7 +983,9 @@ static int fetch_one(struct remote *remote, int argc, const char **argv) sigchain_push_common(unlock_pack_on_signal); atexit(unlock_pack); refspec = parse_fetch_refspec(ref_nr, refs); + prune += remote->prune; exit_code = do_fetch(transport, refspec, ref_nr); + prune -= remote->prune; free_refspec(ref_nr, refspec); transport_disconnect(transport); transport = NULL; diff --git a/builtin/remote.c b/builtin/remote.c index 5e54d36..86e4ed5 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1313,6 +1313,15 @@ static int get_remote_default(const char *key, const char *value, void *priv) return 0; } +static int get_remote_prune(const char *key, const char *value, void *priv) +{ + if (strcmp(key, "remotes.prune") == 0) { + int *found = priv; + *found = git_config_bool(key, value); + } + return 0; +} + static int update(int argc, const char **argv) { int i, prune = 0; @@ -1332,6 +1341,10 @@ static int update(int argc, const char **argv) fetch_argv[fetch_argc++] = "fetch"; + if (!prune) { + git_config(get_remote_prune, &prune); + } + if (prune) fetch_argv[fetch_argc++] = "--prune"; if (verbose) diff --git a/remote.c b/remote.c index 6f57830..e6f2acb 100644 --- a/remote.c +++ b/remote.c @@ -404,6 +404,8 @@ static int handle_config(const char *key, const char *value, void *cb) remote->skip_default_update = git_config_bool(key, value); else if (!strcmp(subkey, ".skipfetchall")) remote->skip_default_update = git_config_bool(key, value); + else if (!strcmp(subkey, ".prune")) + remote->prune = git_config_bool(key, value); else if (!strcmp(subkey, ".url")) { const char *v; if (git_config_string(&v, key, value)) diff --git a/remote.h b/remote.h index cf56724..8a79bd3 100644 --- a/remote.h +++ b/remote.h @@ -41,6 +41,8 @@ struct remote { int skip_default_update; int mirror; + int prune; + const char *receivepack; const char *uploadpack; diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index ee5d65d..a278ac2 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -614,6 +614,39 @@ test_expect_success 'update --prune' ' ) ' +test_expect_success 'prune update by config set remotes.prune' ' + ( + cd test && + git remote update && + git rev-parse refs/remotes/origin/side2 && + git rev-parse refs/remotes/origin/side3 && + git config remotes.prune true && + git remote update && + git config --unset remotes.prune && + test_must_fail git rev-parse refs/remotes/origin/side3 + ) +' + +test_expect_success 'prune update by config set remote.origin.prune' ' + ( + cd one && + git branch -m side2 side3 + ) && + ( + cd test && + git config remote.origin.prune true && + git remote update && + ( + cd ../one && + git branch -m side3 side2 + ) && + git config --unset remote.origin.prune && + git rev-parse refs/remotes/origin/side3 && + test_must_fail git rev-parse refs/remotes/origin/side2 + ) +' + + cat >one/expect <<-\EOF apis/master apis/side -- 1.7.12.4 (Apple Git-37) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html