summaryrefslogtreecommitdiff
path: root/src/transports/git.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-07-24 19:03:22 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-07-30 20:28:16 +0200
commitb49c8f71aef574ce6606282a498627f5106220d5 (patch)
treeb4a9d07716c80b48e68f36d8fb3fb6c142447ac6 /src/transports/git.c
parent114dc6e14c47ff574b4c97d4519782de3f9d28b2 (diff)
downloadlibgit2-b49c8f71aef574ce6606282a498627f5106220d5.tar.gz
remote: use the same code to control git and http
This allows us to add capabilitites to both at the same time, keeps them in sync and removes a lot of code. gitno_buffer now uses a callback to fill its buffer, allowing us to use the same interface for git and http (which uses callbacks).
Diffstat (limited to 'src/transports/git.c')
-rw-r--r--src/transports/git.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/src/transports/git.c b/src/transports/git.c
index f5cdfe7a4..ccd97554f 100644
--- a/src/transports/git.c
+++ b/src/transports/git.c
@@ -156,42 +156,6 @@ static int store_refs(transport_git *t)
}
}
-static int detect_caps(transport_git *t)
-{
- git_vector *refs = &t->refs;
- git_pkt_ref *pkt;
- git_transport_caps *caps = &t->parent.caps;
- const char *ptr;
-
- pkt = git_vector_get(refs, 0);
- /* No refs or capabilites, odd but not a problem */
- if (pkt == NULL || pkt->capabilities == NULL)
- return 0;
-
- ptr = pkt->capabilities;
- while (ptr != NULL && *ptr != '\0') {
- if (*ptr == ' ')
- ptr++;
-
- if(!git__prefixcmp(ptr, GIT_CAP_OFS_DELTA)) {
- caps->common = caps->ofs_delta = 1;
- ptr += strlen(GIT_CAP_OFS_DELTA);
- continue;
- }
-
- if(!git__prefixcmp(ptr, GIT_CAP_MULTI_ACK)) {
- caps->common = caps->multi_ack = 1;
- ptr += strlen(GIT_CAP_MULTI_ACK);
- continue;
- }
-
- /* We don't know this capability, so skip it */
- ptr = strchr(ptr, ' ');
- }
-
- return 0;
-}
-
/*
* Since this is a network connection, we need to parse and store the
* pkt-lines at this stage and keep them there.
@@ -219,7 +183,7 @@ static int git_connect(git_transport *transport, int direction)
if (store_refs(t) < 0)
goto cleanup;
- if (detect_caps(t) < 0)
+ if (git_protocol_detect_caps(git_vector_get(&t->refs, 0), &transport->caps) < 0)
goto cleanup;
return 0;