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>
This commit is contained in:

committed by
Junio C Hamano

parent
97716d217c
commit
6317972cff
@ -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++;
|
||||
|
Reference in New Issue
Block a user