Add config options remotes.prune and remote.<name>.prune
PATCH 1/1 Add config options remotes.prune and remote.<name>.prune
From: "Kirill A. Korinskiy" <[email protected]>
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 <[email protected]>
--- 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(-)
builtin/fetch.c +3 -1
@@ -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 ;
builtin/remote.c +13 -0
@@ -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)
remote.c +2 -0
@@ -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))
remote.h +2 -0
@@ -41,6 +41,8 @@ struct remote {int skip_default_update;int mirror; +int prune; +const char *receivepack;const char *uploadpack;
t/t5505-remote.sh +33 -0
@@ -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
Signature · 1 line
1.7.12.4 (Apple Git-37)