git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Dec 4, 2013, 05:44 UTC
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 <mhagger@alum.mit.edu>
---
 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
Previous: Michael HaggertyNext: Michael Haggerty
Message 10 of 15 in “[RFC 00/11] Make reference pruning more configurable”
  1. Michael HaggertyDec 4, 2013
  2. 01/11 get_stale_heads(): allow limiting to refname patternsMichael Haggerty, Dec 4, 2013
  3. 02/11 remote.c: add infrastructure for parsing --prune optionsMichael Haggerty, Dec 4, 2013
  4. Duy NguyenDec 4, 2013
  5. Michael HaggertyDec 4, 2013
  6. 03/11 fetch: use the new functions for handling --prune optionsMichael Haggerty, Dec 4, 2013
  7. 04/11 remote: use the new functions for handling --prune optionsMichael Haggerty, Dec 4, 2013
  8. 05/11 remote.c: add infrastructure to handle --prune=<pattern>Michael Haggerty, Dec 4, 2013
  9. 06/11 fetch --prune: allow refname patterns to be specifiedMichael Haggerty, Dec 4, 2013
  10. 07/11 remote update --prune: allow refname patterns to be specifiedMichael Haggerty, Dec 4, 2013
  11. 08/11 string_list_append_list(): new functionMichael Haggerty, Dec 4, 2013
  12. 09/11 remote prune: allow --prune=<pattern> optionsMichael Haggerty, Dec 4, 2013
  13. 10/11 remote show: allow --prune=<pattern> optionsMichael Haggerty, Dec 4, 2013
  14. 11/11 remote: allow prune patterns to be configuredMichael Haggerty, Dec 4, 2013
  15. Junio C HamanoDec 4, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.