{"thread":{"id":"34429","subject":"[PATCH] Add config options remotes.prune and remote.<name>.prune","startedAt":"2013-07-13T15:43:07Z","lastAt":"2013-07-13T15:43:07Z","messageCount":1,"participants":["Kirill A. Korinskiy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"223246","messageId":"1373730187-33332-1-git-send-email-catap@catap.ru","threadId":"34429","inReplyTo":null,"subject":"[PATCH] Add config options remotes.prune and remote.<name>.prune","fromName":"Kirill A. Korinskiy","fromEmail":"catap@catap.ru","sentAt":"2013-07-13T15:43:07Z","receivedAt":"2013-07-13T15:43:07Z","isPatch":true,"sender":{"key":"catap@catap.ru","avatar":"https://gravatar.com/avatar/ea0ab2c29579606bd684eccdf786c666f4425bedc4e599b698a175f12737b1c5?d=mp&s=160"},"body":"From: \"Kirill A. Korinskiy\" <catap@catap.ru>\n\nBasic idea is a make behavior `git remote update --prune'\nto `git remote update' as default to specify or all remotes repos.\n\nSigned-off-by: Kirill A. Korinskiy <catap@catap.ru>\n---\n builtin/fetch.c   |  4 +++-\n builtin/remote.c  | 13 +++++++++++++\n remote.c          |  2 ++\n remote.h          |  2 ++\n t/t5505-remote.sh | 33 +++++++++++++++++++++++++++++++++\n 5 files changed, 53 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex d784b2e..cf23218 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -769,7 +769,7 @@ static int do_fetch(struct transport *transport,\n \t\tfree_refs(ref_map);\n \t\tretcode = 1;\n \t\tgoto cleanup;\n-\t}\n+\t}\t\n \tif (prune) {\n \t\t/* If --tags was specified, pretend the user gave us the canonical tags refspec */\n \t\tif (tags == TAGS_SET) {\n@@ -983,7 +983,9 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)\n \tsigchain_push_common(unlock_pack_on_signal);\n \tatexit(unlock_pack);\n \trefspec = parse_fetch_refspec(ref_nr, refs);\n+\tprune += remote->prune;\n \texit_code = do_fetch(transport, refspec, ref_nr);\n+\tprune -= remote->prune;\n \tfree_refspec(ref_nr, refspec);\n \ttransport_disconnect(transport);\n \ttransport = NULL;\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 5e54d36..86e4ed5 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -1313,6 +1313,15 @@ static int get_remote_default(const char *key, const char *value, void *priv)\n \treturn 0;\n }\n \n+static int get_remote_prune(const char *key, const char *value, void *priv)\n+{\n+\tif (strcmp(key, \"remotes.prune\") == 0) {\n+\t\tint *found = priv;\n+\t\t*found = git_config_bool(key, value);\n+\t}\n+\treturn 0;\n+}\n+\n static int update(int argc, const char **argv)\n {\n \tint i, prune = 0;\n@@ -1332,6 +1341,10 @@ static int update(int argc, const char **argv)\n \n \tfetch_argv[fetch_argc++] = \"fetch\";\n \n+\tif (!prune) {\n+\t\tgit_config(get_remote_prune, &prune);\n+\t}\n+\n \tif (prune)\n \t\tfetch_argv[fetch_argc++] = \"--prune\";\n \tif (verbose)\ndiff --git a/remote.c b/remote.c\nindex 6f57830..e6f2acb 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -404,6 +404,8 @@ static int handle_config(const char *key, const char *value, void *cb)\n \t\tremote->skip_default_update = git_config_bool(key, value);\n \telse if (!strcmp(subkey, \".skipfetchall\"))\n \t\tremote->skip_default_update = git_config_bool(key, value);\n+\telse if (!strcmp(subkey, \".prune\"))\n+\t\tremote->prune = git_config_bool(key, value);\n \telse if (!strcmp(subkey, \".url\")) {\n \t\tconst char *v;\n \t\tif (git_config_string(&v, key, value))\ndiff --git a/remote.h b/remote.h\nindex cf56724..8a79bd3 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -41,6 +41,8 @@ struct remote {\n \tint skip_default_update;\n \tint mirror;\n \n+\tint prune;\n+\n \tconst char *receivepack;\n \tconst char *uploadpack;\n \ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex ee5d65d..a278ac2 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -614,6 +614,39 @@ test_expect_success 'update --prune' '\n \t)\n '\n \n+test_expect_success 'prune update by config set remotes.prune' '\n+\t(\n+\t\tcd test &&\n+\t\tgit remote update &&\n+\t\tgit rev-parse refs/remotes/origin/side2 &&\n+\t\tgit rev-parse refs/remotes/origin/side3 &&\n+\t\tgit config remotes.prune true &&\n+\t\tgit remote update &&\n+\t\tgit config --unset remotes.prune &&\n+\t\ttest_must_fail git rev-parse refs/remotes/origin/side3\n+\t)\n+'\n+\n+test_expect_success 'prune update by config set remote.origin.prune' '\n+\t(\n+\t\tcd one &&\n+\t\tgit branch -m side2 side3\n+\t) &&\n+\t(\n+\t\tcd test &&\n+\t\tgit config remote.origin.prune true &&\n+\t\tgit remote update &&\n+\t\t(\n+\t\t\tcd ../one &&\n+\t\t\tgit branch -m side3 side2\n+\t\t) &&\n+\t\tgit config --unset remote.origin.prune &&\n+\t\tgit rev-parse refs/remotes/origin/side3 &&\n+\t\ttest_must_fail git rev-parse refs/remotes/origin/side2\n+\t)\n+'\n+\n+\n cat >one/expect <<-\\EOF\n   apis/master\n   apis/side\n-- \n1.7.12.4 (Apple Git-37)\n"}]}