From: Julien Danjou <julien@danjou.info>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Julien Danjou <julien@danjou.info>
Subject: [PATCH] git-remote: make remote name optional for prune operation
Date: Wed, 6 May 2009 16:37:01 +0200 [thread overview]
Message-ID: <1241620621-12188-1-git-send-email-julien@danjou.info> (raw)
We consider that if `git remote prune` is called without a name, we
actually want to prune all remotes.
Signed-off-by: Julien Danjou <julien@danjou.info>
---
Documentation/git-remote.txt | 2 +-
builtin-remote.c | 26 +++++++++++++++++++++-----
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 9e2b4ea..c566061 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -15,7 +15,7 @@ SYNOPSIS
'git remote rm' <name>
'git remote set-head' <name> [-a | -d | <branch>]
'git remote show' [-n] <name>
-'git remote prune' [-n | --dry-run] <name>
+'git remote prune' [-n | --dry-run] [name]
'git remote update' [-p | --prune] [group | remote]...
DESCRIPTION
diff --git a/builtin-remote.c b/builtin-remote.c
index 2ed752c..053d886 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -14,7 +14,7 @@ static const char * const builtin_remote_usage[] = {
"git remote rm <name>",
"git remote set-head <name> [-a | -d | <branch>]",
"git remote show [-n] <name>",
- "git remote prune [-n | --dry-run] <name>",
+ "git remote prune [-n | --dry-run] [name]",
"git remote [-v | --verbose] update [-p | --prune] [group]",
NULL
};
@@ -25,6 +25,7 @@ static const char * const builtin_remote_usage[] = {
static int verbose;
+static int get_one_entry(struct remote *remote, void *priv);
static int show_all(void);
static int prune_remote(const char *remote, int dry_run);
@@ -1133,10 +1134,25 @@ static int prune(int argc, const char **argv)
argc = parse_options(argc, argv, options, builtin_remote_usage, 0);
if (argc < 1)
- usage_with_options(builtin_remote_usage, options);
+ {
+ struct string_list list = { NULL, 0, 0 };
+ int result = for_each_remote(get_one_entry, &list);
+
+ if (!result) {
+ int i;
- for (; argc; argc--, argv++)
- result |= prune_remote(*argv, dry_run);
+ sort_string_list(&list);
+ for (i = 0; i < list.nr; i++) {
+ struct string_list_item *item = list.items + i;
+ if (i && !strcmp((item - 1)->string, item->string))
+ continue;
+ result |= prune_remote(item->string, dry_run);
+ }
+ }
+ }
+ else
+ for (; argc; argc--, argv++)
+ result |= prune_remote(*argv, dry_run);
return result;
}
--
1.6.2.4
next reply other threads:[~2009-05-06 14:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-06 14:37 Julien Danjou [this message]
2009-05-06 14:49 ` [PATCH] git-remote: make remote name optional for prune operation Francis Galiegue
2009-05-06 15:32 ` Julien Danjou
2009-05-06 15:46 ` Jacob Helwig
2009-05-06 16:15 ` Michael J Gruber
2009-05-06 16:58 ` Julien Danjou
2009-05-06 17:18 ` Junio C Hamano
2009-05-06 17:54 ` Junio C Hamano
2009-05-06 17:55 ` Finn Arne Gangstad
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=1241620621-12188-1-git-send-email-julien@danjou.info \
--to=julien@danjou.info \
--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.
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).