summaryrefslogtreecommitdiff
path: root/src/transports/smart_protocol.c
diff options
context:
space:
mode:
authorEtienne Samson <samson.etienne@gmail.com>2019-07-31 08:37:10 +0200
committerEtienne Samson <samson.etienne@gmail.com>2019-08-21 12:22:03 +0200
commit39d18fe676382cf29ea08427b8ad4527ef51a4bb (patch)
tree55bf3ad2b561b1f5ee9370142b2cf89b5e5b6b82 /src/transports/smart_protocol.c
parent0f40e68e2f468169d711a806f6839781ae4f7a3e (diff)
downloadlibgit2-39d18fe676382cf29ea08427b8ad4527ef51a4bb.tar.gz
smart: use push_glob instead of manual filtering
The code worked under the assumption that anything under `refs/tags` are tag objects, and all the rest would be peelable to a commit. As it is completely valid to have tags to blobs under a non `refs/tags` ref, this would cause failures when trying to peel a tag to a commit. Fix the broken filtering by switching to `git_revwalk_push_glob`, which already handles this case.
Diffstat (limited to 'src/transports/smart_protocol.c')
-rw-r--r--src/transports/smart_protocol.c49
1 files changed, 4 insertions, 45 deletions
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index cfbe7e4d1..1a8ede580 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -270,50 +270,6 @@ static int store_common(transport_smart *t)
return 0;
}
-static int fetch_setup_walk(git_revwalk **out, git_repository *repo)
-{
- git_revwalk *walk = NULL;
- git_strarray refs;
- unsigned int i;
- git_reference *ref = NULL;
- int error;
-
- if ((error = git_reference_list(&refs, repo)) < 0)
- return error;
-
- if ((error = git_revwalk_new(&walk, repo)) < 0)
- return error;
-
- git_revwalk_sorting(walk, GIT_SORT_TIME);
-
- for (i = 0; i < refs.count; ++i) {
- git_reference_free(ref);
- ref = NULL;
-
- /* No tags */
- if (!git__prefixcmp(refs.strings[i], GIT_REFS_TAGS_DIR))
- continue;
-
- if ((error = git_reference_lookup(&ref, repo, refs.strings[i])) < 0)
- goto on_error;
-
- if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC)
- continue;
-
- if ((error = git_revwalk_push(walk, git_reference_target(ref))) < 0)
- goto on_error;
- }
-
- *out = walk;
-
-on_error:
- if (error)
- git_revwalk_free(walk);
- git_reference_free(ref);
- git_strarray_free(&refs);
- return error;
-}
-
static int wait_while_ack(gitno_buffer *buf)
{
int error;
@@ -358,7 +314,10 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
if ((error = git_pkt_buffer_wants(wants, count, &t->caps, &data)) < 0)
return error;
- if ((error = fetch_setup_walk(&walk, repo)) < 0)
+ if ((error = git_revwalk_new(&walk, repo)) < 0)
+ goto on_error;
+
+ if ((error = git_revwalk_push_glob(walk, "refs/*")) < 0)
goto on_error;
/*