diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2018-02-09 20:32:16 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-09 13:10:13 -0800 |
commit | 6317972cff9b4df7a6cc666b08be7133ba81617c (patch) | |
tree | acbb3ab75f127187d608c7fe9f1b07dc5334d7a8 /builtin | |
parent | fetch: add a --prune-tags option and fetch.pruneTags config (diff) | |
download | tgif-6317972cff9b4df7a6cc666b08be7133ba81617c.tar.xz |
fetch: make the --prune-tags work with <url>
Make the new --prune-tags option work properly when git-fetch is
invoked with a <url> parameter instead of a <remote name>
parameter.
This change is split off from the introduction of --prune-tags due to
the relative complexity of munging the incoming argv, which is easier
to review as a separate change.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/fetch.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c index 55a0fc37be..c96f17a9a3 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1283,7 +1283,10 @@ static int fetch_one(struct remote *remote, int argc, const char **argv, int pru static const char **refs = NULL; struct refspec *refspec; int ref_nr = 0; + int j = 0; int exit_code; + int maybe_prune_tags; + int remote_via_config = remote_is_configured(remote, 0); if (!remote) die(_("No remote repository specified. Please, specify either a URL or a\n" @@ -1311,13 +1314,21 @@ static int fetch_one(struct remote *remote, int argc, const char **argv, int pru prune_tags = PRUNE_TAGS_BY_DEFAULT; } - if (prune_tags_ok && prune_tags && remote_is_configured(remote, 0)) + maybe_prune_tags = prune_tags_ok && prune_tags; + if (maybe_prune_tags && remote_via_config) add_prune_tags_to_fetch_refspec(remote); + if (argc > 0 || (maybe_prune_tags && !remote_via_config)) { + size_t nr_alloc = st_add3(argc, maybe_prune_tags, 1); + refs = xcalloc(nr_alloc, sizeof(const char *)); + if (maybe_prune_tags) { + refs[j++] = xstrdup("refs/tags/*:refs/tags/*"); + ref_nr++; + } + } + if (argc > 0) { - int j = 0; int i; - refs = xcalloc(st_add(argc, 1), sizeof(const char *)); for (i = 0; i < argc; i++) { if (!strcmp(argv[i], "tag")) { i++; |