summaryrefslogtreecommitdiff
path: root/connect.c
diff options
context:
space:
mode:
authorLibravatar Linus Torvalds <torvalds@g5.osdl.org>2005-07-05 15:44:09 -0700
committerLibravatar Linus Torvalds <torvalds@g5.osdl.org>2005-07-05 15:44:09 -0700
commit41cb7488b9e5998ce1d665bbe10beca0a0f69c1c (patch)
tree5003dbc48bb4250e3984666787fc0bec0eb9b3af /connect.c
parentRemove multi-head support from fetch-pack (diff)
downloadtgif-41cb7488b9e5998ce1d665bbe10beca0a0f69c1c.tar.xz
Move "get_ack()" to common git_connect functions
git-clone-pack will want it too. Soon.
Diffstat (limited to 'connect.c')
-rw-r--r--connect.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/connect.c b/connect.c
index 941bf296b0..075683e83c 100644
--- a/connect.c
+++ b/connect.c
@@ -1,6 +1,25 @@
#include "cache.h"
+#include "pkt-line.h"
#include <sys/wait.h>
+int get_ack(int fd, unsigned char *result_sha1)
+{
+ static char line[1000];
+ int len = packet_read_line(fd, line, sizeof(line));
+
+ if (!len)
+ die("git-fetch-pack: expected ACK/NAK, got EOF");
+ if (line[len-1] == '\n')
+ line[--len] = 0;
+ if (!strcmp(line, "NAK"))
+ return 0;
+ if (!strncmp(line, "ACK ", 3)) {
+ if (!get_sha1_hex(line+4, result_sha1))
+ return 1;
+ }
+ die("git-fetch_pack: expected ACK/NAK, got '%s'", line);
+}
+
int path_match(const char *path, int nr, char **match)
{
int i;