From: Michael Haggerty Date: Wed, 04 Dec 2013 05:44:46 GMT Subject: [RFC 07/11] remote update --prune: allow refname patterns to be specified Message-ID: <1386135890-13954-8-git-send-email-mhagger@alum.mit.edu> In-Reply-To: <1386135890-13954-1-git-send-email-mhagger@alum.mit.edu> Allow optional arguments to be passed to "git remote update --prune" to choose which references are subject to pruning. The default, if no argument is specified, is to prune all references as before. Signed-off-by: Michael Haggerty --- Documentation/git-remote.txt | 7 +++++-- builtin/remote.c | 9 ++++++--- t/t5505-remote.sh | 13 +++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt index 2507c8b..02e50a9 100644 --- a/Documentation/git-remote.txt +++ b/Documentation/git-remote.txt @@ -20,7 +20,8 @@ SYNOPSIS 'git remote set-url --delete' [--push] 'git remote' [-v | --verbose] 'show' [-n] ... 'git remote prune' [-n | --dry-run] ... -'git remote' [-v | --verbose] 'update' [-p | --prune] [( | )...] +'git remote' [-v | --verbose] 'update' [-p | --no-prune | --prune[=]...] + [( | )...] DESCRIPTION ----------- @@ -168,7 +169,9 @@ remotes.default is not defined, all remotes which do not have the configuration parameter remote..skipDefaultUpdate set to true will be updated. (See linkgit:git-config[1]). + -With `--prune` option, prune all the remotes that are updated. +The options `--prune`, `--no-prune`, and `--prune=` affect +whether remote-tracking branches associated with the remotes are +pruned. See linkgit:git-fetch[1] for more information. DISCUSSION diff --git a/builtin/remote.c b/builtin/remote.c index 09b965a..6aab923 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -16,7 +16,7 @@ static const char * const builtin_remote_usage[] = { N_("git remote set-head (-a | --auto | -d | --delete |)"), N_("git remote [-v | --verbose] show [-n] "), N_("git remote prune [-n | --dry-run] "), - N_("git remote [-v | --verbose] update [-p | --prune] [( | )...]"), + N_("git remote [-v | --verbose] update [-p | --prune[=] | --no-prune] [( | )...]"), N_("git remote set-branches [--add] ..."), N_("git remote set-url [--push] []"), N_("git remote set-url --add "), @@ -1375,9 +1375,12 @@ static int update(int argc, const char **argv) int i; struct prune_option prune_option = PRUNE_OPTION_INIT; struct option options[] = { - { OPTION_CALLBACK, 'p', "prune", &prune_option, N_("pattern"), - N_("prune remotes after fetching"), + { OPTION_CALLBACK, 'p', NULL, &prune_option, NULL, + N_("prune remote-tracking branches no longer on remote"), PARSE_OPT_NOARG, prune_option_parse }, + { OPTION_CALLBACK, 0, "prune", &prune_option, N_("pattern"), + N_("prune remote-tracking branches (matching pattern, if specified)"), + PARSE_OPT_OPTARG, prune_option_parse }, OPT_END() }; struct argv_array fetch_argv = ARGV_ARRAY_INIT; diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 8f6e392..0dffe47 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -614,6 +614,19 @@ test_expect_success 'update --prune' ' ) ' +test_expect_success 'update --prune with argument' ' + git clone one update-prune-arg && + ( + cd update-prune-arg && + git update-ref refs/remotes/origin/branch1 master && + git update-ref refs/remotes/origin/branch2 master && + + git remote update --prune="refs/remotes/*1" origin && + test_must_fail git rev-parse origin/branch1 && + git rev-parse origin/branch2 + ) +' + cat >one/expect <<-\EOF apis/master apis/side -- 1.8.4.3