While we're at it, wrap a long line to fit on a 80 char terminal. Signed-off-by: Erik Faye-Lund <kusmabite@xxxxxxxxx> --- I recently needed to prune remote branches in a repo with a lot of remotes, and to my surprise "git remote prune" didn't support the --all option. So I added it. Perhaps this is useful for other people as well? Documentation/git-remote.txt | 2 +- builtin/remote.c | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt index 5a8c506..856cc7f 100644 --- a/Documentation/git-remote.txt +++ b/Documentation/git-remote.txt @@ -19,7 +19,7 @@ SYNOPSIS 'git remote set-url --add' [--push] <name> <newurl> 'git remote set-url --delete' [--push] <name> <url> 'git remote' [-v | --verbose] 'show' [-n] <name> -'git remote prune' [-n | --dry-run] <name> +'git remote prune' [-n | --dry-run] (--all | <name>...) 'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...] DESCRIPTION diff --git a/builtin/remote.c b/builtin/remote.c index f2a9c26..2e8407d 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 [-v | --verbose] show [-n] <name>", - "git remote prune [-n | --dry-run] <name>", + "git remote prune [-n | --dry-run] (--all | <name>)", "git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]", "git remote set-branches <name> [--add] <branch>...", "git remote set-url <name> <newurl> [<oldurl>]", @@ -1222,22 +1222,35 @@ static int set_head(int argc, const char **argv) return result; } +static int add_one_remote(struct remote *remote, void *remotes) +{ + string_list_append(remotes, remote->name); + return 0; +} + static int prune(int argc, const char **argv) { - int dry_run = 0, result = 0; + struct string_list remotes = STRING_LIST_INIT_NODUP; + int dry_run = 0, result = 0, all = 0, i; struct option options[] = { + OPT_BOOLEAN(0, "all", &all, "prune all remotes"), OPT__DRY_RUN(&dry_run, "dry run"), OPT_END() }; - argc = parse_options(argc, argv, NULL, options, builtin_remote_prune_usage, - 0); + argc = parse_options(argc, argv, NULL, options, + builtin_remote_prune_usage, 0); - if (argc < 1) + if (all) + for_each_remote(add_one_remote, &remotes); + else if (argc < 1) usage_with_options(builtin_remote_prune_usage, options); + else + for (; argc; argc--, argv++) + string_list_append(&remotes, *argv); - for (; argc; argc--, argv++) - result |= prune_remote(*argv, dry_run); + for (i = 0; i < remotes.nr; ++i) + result |= prune_remote(remotes.items[i].string, dry_run); return result; } -- 1.7.6.msysgit.0.579.ga3d6f -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html