From: Michael Haggerty <mhagger@alum.mit.edu>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Michael Haggerty <mhagger@alum.mit.edu>
Subject: [RFC 06/11] fetch --prune: allow refname patterns to be specified
Date: Wed, 4 Dec 2013 06:44:45 +0100 [thread overview]
Message-ID: <1386135890-13954-7-git-send-email-mhagger@alum.mit.edu> (raw)
In-Reply-To: <1386135890-13954-1-git-send-email-mhagger@alum.mit.edu>
Allow optional arguments to be passed to "git fetch --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/fetch-options.txt | 6 +++++-
builtin/fetch.c | 8 ++++++--
t/t5510-fetch.sh | 12 ++++++++++++
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index f0ef7d0..61d3f75 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -40,7 +40,7 @@ ifndef::git-pull[]
specified. No <refspec>s may be specified.
-p::
---prune::
+--prune[=<pattern>]::
After fetching, remove any remote-tracking references that no
longer exist on the remote. Tags are not subject to pruning
if they are fetched only because of the default tag
@@ -49,6 +49,10 @@ ifndef::git-pull[]
line or in the remote configuration, for example if the remote
was cloned with the --mirror option), then they are also
subject to pruning.
++
+If pattern is specified, then it should be a glob pattern, and pruning
+is further restricted to references whose names match the pattern.
+This option can be specified multiple times.
endif::git-pull[]
ifndef::git-pull[]
diff --git a/builtin/fetch.c b/builtin/fetch.c
index fcc06a4..2cb48a6 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -73,9 +73,12 @@ static struct option builtin_fetch_options[] = {
N_("fetch all tags and associated objects"), TAGS_SET),
OPT_SET_INT('n', NULL, &tags,
N_("do not fetch all tags (--no-tags)"), TAGS_UNSET),
- { OPTION_CALLBACK, 'p', "prune", &prune_option, N_("pattern"),
+ { 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 },
{ OPTION_CALLBACK, 0, "recurse-submodules", NULL, N_("on-demand"),
N_("control recursive fetching of submodules"),
PARSE_OPT_OPTARG, option_parse_recurse_submodules },
@@ -702,7 +705,8 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map)
{
int result = 0;
- struct ref *stale_refs = get_stale_heads(refs, ref_count, ref_map, NULL);
+ struct ref *stale_refs = get_stale_heads(refs, ref_count, ref_map,
+ &prune_option.prune_patterns);
struct ref *ref;
const char *dangling_msg = dry_run
? _(" (%s will become dangling)")
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 5d4581d..42eb21f 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -94,6 +94,18 @@ test_expect_success 'fetch --prune on its own works as expected' '
test_must_fail git rev-parse origin/extrabranch
'
+test_expect_success 'fetch --prune with arguments' '
+ cd "$D" &&
+ git clone . prune-args &&
+ cd prune-args &&
+ git update-ref refs/remotes/origin/branch1 master &&
+ git update-ref refs/remotes/origin/branch2 master &&
+
+ git fetch --prune="refs/remotes/origin/*1" origin &&
+ test_must_fail git rev-parse origin/branch1 &&
+ git rev-parse origin/branch2
+'
+
test_expect_success 'fetch --prune with a branch name keeps branches' '
cd "$D" &&
git clone . prune-branch &&
--
1.8.4.3
next prev parent reply other threads:[~2013-12-04 5:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-04 5:44 [RFC 00/11] Make reference pruning more configurable Michael Haggerty
2013-12-04 5:44 ` [RFC 01/11] get_stale_heads(): allow limiting to refname patterns Michael Haggerty
2013-12-04 5:44 ` [RFC 02/11] remote.c: add infrastructure for parsing --prune options Michael Haggerty
2013-12-04 12:57 ` Duy Nguyen
2013-12-04 17:04 ` Michael Haggerty
2013-12-04 5:44 ` [RFC 03/11] fetch: use the new functions for handling " Michael Haggerty
2013-12-04 5:44 ` [RFC 04/11] remote: " Michael Haggerty
2013-12-04 5:44 ` [RFC 05/11] remote.c: add infrastructure to handle --prune=<pattern> Michael Haggerty
2013-12-04 5:44 ` Michael Haggerty [this message]
2013-12-04 5:44 ` [RFC 07/11] remote update --prune: allow refname patterns to be specified Michael Haggerty
2013-12-04 5:44 ` [RFC 08/11] string_list_append_list(): new function Michael Haggerty
2013-12-04 5:44 ` [RFC 09/11] remote prune: allow --prune=<pattern> options Michael Haggerty
2013-12-04 5:44 ` [RFC 10/11] remote show: " Michael Haggerty
2013-12-04 5:44 ` [RFC 11/11] remote: allow prune patterns to be configured Michael Haggerty
2013-12-04 20:25 ` [RFC 00/11] Make reference pruning more configurable Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386135890-13954-7-git-send-email-mhagger@alum.mit.edu \
--to=mhagger@alum.mit.edu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).