diff options
author | Finn Arne Gangstad <finnag@pvv.org> | 2009-04-03 11:03:44 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-04-05 01:52:38 -0700 |
commit | efa54803cb1dc15923799f94abf82cb0433c2b9b (patch) | |
tree | 6cb4725a694addf74782160c0ccf06795cbd9fb9 /builtin-remote.c | |
parent | b92c5f228a9c07fe339c8fd5406069602b6452f6 (diff) | |
download | git-efa54803cb1dc15923799f94abf82cb0433c2b9b.tar.gz |
git remote update: New option --prune
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-remote.c')
-rw-r--r-- | builtin-remote.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/builtin-remote.c b/builtin-remote.c index c53966fd8d..3146eb467d 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 }; @@ -1208,10 +1208,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; @@ -1226,8 +1234,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; |