[RFC 07/11] remote update --prune: allow refname patterns to be specified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <mhagger@xxxxxxxxxxxx>
---
 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] <name> <url>
 'git remote' [-v | --verbose] 'show' [-n] <name>...
 'git remote prune' [-n | --dry-run] <name>...
-'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...]
+'git remote' [-v | --verbose] 'update' [-p | --no-prune | --prune[=<pattern>]...]
+				       [(<group> | <remote>)...]
 
 DESCRIPTION
 -----------
@@ -168,7 +169,9 @@ 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.
+The options `--prune`, `--no-prune`, and `--prune=<pattern>` 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 <name> (-a | --auto | -d | --delete |<branch>)"),
 	N_("git remote [-v | --verbose] show [-n] <name>"),
 	N_("git remote prune [-n | --dry-run] <name>"),
-	N_("git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]"),
+	N_("git remote [-v | --verbose] update [-p | --prune[=<pattern>] | --no-prune] [(<group> | <remote>)...]"),
 	N_("git remote set-branches [--add] <name> <branch>..."),
 	N_("git remote set-url [--push] <name> <newurl> [<oldurl>]"),
 	N_("git remote set-url --add <name> <newurl>"),
@@ -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

--
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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]