]> git.proxmox.com Git - libgit2.git/commitdiff
Changed GIT_REMOTE_DOWNLOAD_TAGS_ALL to behave like git 1.9.0
authorPierre-Olivier Latour <pol@mac.com>
Wed, 29 Oct 2014 05:18:38 +0000 (22:18 -0700)
committerPierre-Olivier Latour <pol@mac.com>
Sat, 8 Nov 2014 22:27:30 +0000 (07:27 +0900)
CHANGELOG.md
src/fetch.c
src/remote.c
tests/network/remote/local.c

index 0e7929cdcc5b6173e1c881b8b994cf166960ea70..f268f6f598c2927b333545d979e1bdb28003bb46 100644 (file)
@@ -118,3 +118,7 @@ v0.21 + 1
 
 * git_status_file now takes an exact path. Use git_status_list_new if
   pathspec searching is needed.
+
+* The fetch behavior of remotes with autotag set to GIT_REMOTE_DOWNLOAD_TAGS_ALL
+  has been changed to match git 1.9.0 and later. In this mode, libgit2 now
+  fetches all tags in addition to whatever else needs to be fetched.
index 9ff95d935990098b1b4310ac885df66746e06f6c..f616856197462ba5e7bef2894f6c593ebd19b68d 100644 (file)
@@ -28,15 +28,15 @@ static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, g
 
        if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
                /*
-                * If tagopt is --tags, then we only use the default
-                * tags refspec and ignore the remote's
+                * If tagopt is --tags, always request tags
+                * in addition to the remote's refspecs
                 */
                if (git_refspec_src_matches(tagspec, head->name))
                        match = 1;
-               else
-                       return 0;
-       } else if (git_remote__matching_refspec(remote, head->name))
-                       match = 1;
+       }
+
+       if (!match && git_remote__matching_refspec(remote, head->name))
+               match = 1;
 
        if (!match)
                return 0;
index 220695413d3ff239ef8414c0c5eca5bb25185b65..cc9f85cd1a404cf640d71d739343858efc954bf9 100644 (file)
@@ -1098,24 +1098,26 @@ static int update_tips_for_spec(
                if (!git_reference_is_valid_name(head->name))
                        continue;
 
-               if (git_refspec_src_matches(spec, head->name) && spec->dst) {
-                       if (git_refspec_transform(&refname, spec, head->name) < 0)
-                               goto on_error;
-               } else if (remote->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
+               if (git_refspec_src_matches(&tagspec, head->name)) {
+                       if (remote->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
 
-                       if (remote->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_ALL)
-                               autotag = 1;
+                               if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_AUTO)
+                                       autotag = 1;
 
-                       if (!git_refspec_src_matches(&tagspec, head->name))
+                               git_buf_clear(&refname);
+                               if (git_buf_puts(&refname, head->name) < 0)
+                                       goto on_error;
+                       } else {
                                continue;
-
-                       git_buf_clear(&refname);
-                       if (git_buf_puts(&refname, head->name) < 0)
+                       }
+               } else if (git_refspec_src_matches(spec, head->name) && spec->dst) {
+                       if (git_refspec_transform(&refname, spec, head->name) < 0)
                                goto on_error;
                } else {
                        continue;
                }
 
+               /* In autotag mode, only create tags for objects already in db */
                if (autotag && !git_odb_exists(odb, &head->oid))
                        continue;
 
@@ -1276,8 +1278,8 @@ int git_remote_update_tips(
                goto out;
 
        if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
-               error = update_tips_for_spec(remote, &tagspec, &refs, signature, reflog_message);
-               goto out;
+               if ((error = update_tips_for_spec(remote, &tagspec, &refs, signature, reflog_message)) < 0)
+                       goto out;
        }
 
        git_vector_foreach(&remote->active_refspecs, i, spec) {
index 7e575b7b96fd4abfdf891dc6fdd5dd4dda1549ea..a69af645da293e91f80691df599e8a1d7ebf52e2 100644 (file)
@@ -171,7 +171,7 @@ void test_network_remote_local__tagopt(void)
        git_remote_set_autotag(remote, GIT_REMOTE_DOWNLOAD_TAGS_ALL);
        cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
 
-       cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/tagopt/master"));
+       cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/tagopt/master"));
        cl_git_pass(git_reference_lookup(&ref, repo, "refs/tags/hard_tag"));
        git_reference_free(ref);