From: Finn Arne Gangstad <finnag@pvv.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, demerphq <demerphq@gmail.com>,
git@vger.kernel.org
Subject: [PATCHv2 2/2] git remote update: New option --prune
Date: Fri, 3 Apr 2009 11:03:44 +0200 [thread overview]
Message-ID: <20090403090344.GB5199@pvv.org> (raw)
In-Reply-To: <20090403090036.GA23955@pvv.org>
With the --prune (or -p) option, git remote update will also prune
all the remotes that it fetches. Previously, you had to do a manual
git remote prune <remote> for each of the remotes you wanted to
prune, and this could be tedious with many remotes.
A single command will now update a set of remotes, and remove all
stale branches: git remote update -p [group]
Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
Documentation/git-remote.txt | 4 +++-
builtin-remote.c | 20 ++++++++++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index c9c0e6f..0b6e67d 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -16,7 +16,7 @@ SYNOPSIS
'git remote set-head' <name> [-a | -d | <branch>]
'git remote show' [-n] <name>
'git remote prune' [-n | --dry-run] <name>
-'git remote update' [group]
+'git remote update' [-p | --prune] [group]
DESCRIPTION
-----------
@@ -125,6 +125,8 @@ the configuration parameter remotes.default will get used; if
remotes.default is not defined, all remotes which do not have the
configuration parameter remote.<name>.skipDefaultUpdate set to true will
be updated. (See linkgit:git-config[1]).
++
+With `--prune` option, prune all the remotes that are updated.
DISCUSSION
diff --git a/builtin-remote.c b/builtin-remote.c
index 9804d6c..c8e5b17 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -15,7 +15,7 @@ static const char * const builtin_remote_usage[] = {
"git remote set-head <name> [-a | -d | <branch>]",
"git remote show [-n] <name>",
"git remote prune [-n | --dry-run] <name>",
- "git remote [-v | --verbose] update [group]",
+ "git remote [-v | --verbose] update [-p | --prune] [group]",
NULL
};
@@ -1210,10 +1210,18 @@ static int get_remote_group(const char *key, const char *value, void *cb)
static int update(int argc, const char **argv)
{
- int i, result = 0;
+ int i, result = 0, prune = 0;
struct string_list list = { NULL, 0, 0, 0 };
static const char *default_argv[] = { NULL, "default", NULL };
+ struct option options[] = {
+ OPT_GROUP("update specific options"),
+ OPT_BOOLEAN('p', "prune", &prune,
+ "prune remotes after fecthing"),
+ OPT_END()
+ };
+ argc = parse_options(argc, argv, options, builtin_remote_usage,
+ PARSE_OPT_KEEP_ARGV0);
if (argc < 2) {
argc = 2;
argv = default_argv;
@@ -1228,8 +1236,12 @@ static int update(int argc, const char **argv)
if (!result && !list.nr && argc == 2 && !strcmp(argv[1], "default"))
result = for_each_remote(get_one_remote_for_update, &list);
- for (i = 0; i < list.nr; i++)
- result |= fetch_remote(list.items[i].string);
+ for (i = 0; i < list.nr; i++) {
+ int err = fetch_remote(list.items[i].string);
+ result |= err;
+ if (!err && prune)
+ result |= prune_remote(list.items[i].string, 0);
+ }
/* all names were strdup()ed or strndup()ed */
list.strdup_strings = 1;
--
1.6.2.1.471.gdeb91.dirty
next prev parent reply other threads:[~2009-04-03 9:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-02 12:38 [PATCH] git remote update: New option --prune (-p) Finn Arne Gangstad
2009-04-02 13:34 ` demerphq
2009-04-02 13:44 ` Jeff King
2009-04-02 14:17 ` demerphq
2009-04-02 14:31 ` Jeff King
2009-04-02 16:07 ` demerphq
2009-04-02 16:32 ` Jeff King
2009-04-02 19:05 ` demerphq
2009-04-02 18:06 ` Junio C Hamano
2009-04-02 20:18 ` Finn Arne Gangstad
2009-04-02 20:52 ` Junio C Hamano
2009-04-03 9:00 ` [PATCHv2 0/2] " Finn Arne Gangstad
2009-04-03 9:02 ` [PATCHv2 1/2] builtin-remote.c: Split out prune_remote as a separate function Finn Arne Gangstad
2009-04-03 9:03 ` Finn Arne Gangstad [this message]
2009-04-05 9:47 ` [PATCHv2 2/2] git remote update: New option --prune Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090403090344.GB5199@pvv.org \
--to=finnag@pvv.org \
--cc=demerphq@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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.
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 NNTP newsgroup(s).