summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-06-25 00:23:48 +0200
committerVicent Marti <tanoku@gmail.com>2011-08-18 02:34:07 +0200
commit0132cf64388adbba3d8f779e1adb0cbf45549dd3 (patch)
tree4666e1b66e211cc8e989776bfea5c0e1a0de74f2
parente1f4a761506f61f05e74265633aec76cf75cbd50 (diff)
downloadlibgit2-0132cf64388adbba3d8f779e1adb0cbf45549dd3.tar.gz
git_pkt_send_wants
-rw-r--r--src/pkt.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/pkt.c b/src/pkt.c
index 215909055..f75b83383 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -209,3 +209,29 @@ int git_pkt_send_flush(int s)
return gitno_send(s, flush, STRLEN(flush), 0);
}
+
+/*
+ * All "want" packets have the same length and format, so what we do
+ * is overwrite the OID each time.
+ */
+#define WANT_PREFIX "0032want "
+
+int git_pkt_send_wants(git_headarray *refs)
+{
+ unsigned int i;
+ int ret = GIT_SUCCESS;
+ char buf[STRLEN(WANT_PREFIX) + GIT_OID_HEXSZ + 2];
+ git_remote_head *head;
+
+ memcpy(buf, WANT_PREFIX, STRLEN(WANT_PREFIX));
+ buf[sizeof(buf) - 2] = '\n';
+ buf[sizeof(buf) - 1] = '\0';
+
+ for (i = 0; i < refs->len; ++i) {
+ head = refs->heads[i];
+ git_oid_fmt(buf + STRLEN(WANT_PREFIX), &head->oid);
+ printf("would send %s\n", buf);
+ }
+
+ return ret;
+}