Move "get_ack()" to common git_connect functions
authorLinus Torvalds <torvalds@g5.osdl.org>
Tue, 5 Jul 2005 22:44:09 +0000 (15:44 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 5 Jul 2005 22:44:09 +0000 (15:44 -0700)
git-clone-pack will want it too. Soon.

cache.h
connect.c
fetch-pack.c

diff --git a/cache.h b/cache.h
index c84e797fdb4f6988a6a8a3294ee6de5d11951276..cc7b6db4b34b765a7d24827559c22c31bdb6309b 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -263,6 +263,7 @@ struct pack_entry {
 extern int git_connect(int fd[2], char *url, const char *prog);
 extern int finish_connect(pid_t pid);
 extern int path_match(const char *path, int nr, char **match);
+extern int get_ack(int fd, unsigned char *result_sha1);
 
 extern void prepare_packed_git(void);
 extern int use_packed_git(struct packed_git *);
index 941bf296b0d5a8ded60cea0ed61770dc909d2d88..075683e83c48282dfbd2626e89047af398cc7e4d 100644 (file)
--- 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;
index 96ce7f5d5abd9faf66a189e583161e5860f582ef..ec5bad89cdb3f6eae038877856f2eefb1125bf6f 100644 (file)
@@ -6,24 +6,6 @@
 static const char fetch_pack_usage[] = "git-fetch-pack [host:]directory [heads]* < mycommitlist";
 static const char *exec = "git-upload-pack";
 
-static 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);
-}
-
 static int find_common(int fd[2], unsigned char *result_sha1, unsigned char *remote)
 {
        static char line[1000];