summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-08-11 22:51:53 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-08-11 22:51:53 +0200
commite3e017d4839893cb6e5339b063afafa60b56bf0d (patch)
tree46f15328ed255eaf1817c9e737f7e0989580ef46
parenta879276783de5cc2c82543a9f930337f000aa8e5 (diff)
downloadlibgit2-cmn/mirror-refspec.tar.gz
remote: don't confuse tag auto-follow rules with refspec matchingcmn/mirror-refspec
When we're looking to update a tag, we can't stop if the tag auto-follow rules don't say to update it. The tag might still match the refspec we were given.
-rw-r--r--src/remote.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/remote.c b/src/remote.c
index d31e1b89e..7404bf49f 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -1334,11 +1334,13 @@ static int update_tips_for_spec(
for (; i < refs->length; ++i) {
head = git_vector_get(refs, i);
autotag = 0;
+ git_buf_clear(&refname);
/* Ignore malformed ref names (which also saves us from tag^{} */
if (!git_reference_is_valid_name(head->name))
continue;
+ /* If we have a tag, see if the auto-follow rules say to update it */
if (git_refspec_src_matches(&tagspec, head->name)) {
if (tagopt != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
@@ -1348,10 +1350,11 @@ static int update_tips_for_spec(
git_buf_clear(&refname);
if (git_buf_puts(&refname, head->name) < 0)
goto on_error;
- } else {
- continue;
}
- } else if (git_refspec_src_matches(spec, head->name)) {
+ }
+
+ /* If we didn't want to auto-follow the tag, check if the refspec matches */
+ if (!autotag && git_refspec_src_matches(spec, head->name)) {
if (spec->dst) {
if (git_refspec_transform(&refname, spec, head->name) < 0)
goto on_error;
@@ -1365,7 +1368,10 @@ static int update_tips_for_spec(
continue;
}
- } else {
+ }
+
+ /* If we still don't have a refname, we don't want it */
+ if (git_buf_len(&refname) == 0) {
continue;
}