From: "Kirill A. Korinskiy" <catap@catap.ru>
To: gitster@pobox.com
Cc: git@vger.kernel.org, "Kirill A. Korinskiy" <catap@catap.ru>
Subject: [PATCH] Add config options remotes.prune and remote.<name>.prune
Date: Sat, 13 Jul 2013 19:43:07 +0400 [thread overview]
Message-ID: <1373730187-33332-1-git-send-email-catap@catap.ru> (raw)
From: "Kirill A. Korinskiy" <catap@catap.ru>
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@catap.ru>
---
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)
reply other threads:[~2013-07-13 15:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1373730187-33332-1-git-send-email-catap@catap.ru \
--to=catap@catap.ru \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).