Move "get_ack()" back to fetch-pack
In 41cb7488 Linus moved this function to connect.c for reuse inside of the git-clone-pack command. That was 2005, but in 2006 Junio retired git-clone-pack in commit efc7fa53. Since then the only caller has been fetch-pack. Since this ACK/NAK exchange is only used by the fetch-pack/upload-pack protocol we should move it back to be a private detail of fetch-pack. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shawn O. Pearce committed
Oct 30, 2009 at 17:47 UTC
28754ab5f0ce9b4f6ca1641c3e10e2c68bd9b3fc
3 files changed
+21
-22
builtin-fetch-pack.c
+21
@@ -157,6 +157,27 @@ static const unsigned char *get_rev(void)
157
return commit->object.sha1;
158
}
159
160
+static int get_ack(int fd, unsigned char *result_sha1)
161
+{
162
+ static char line[1000];
163
+ int len = packet_read_line(fd, line, sizeof(line));
164
+
165
+ if (!len)
166
+ die("git fetch-pack: expected ACK/NAK, got EOF");
167
+ if (line[len-1] == '\n')
168
+ line[--len] = 0;
169
+ if (!strcmp(line, "NAK"))
170
+ return 0;
171
+ if (!prefixcmp(line, "ACK ")) {
172
+ if (!get_sha1_hex(line+4, result_sha1)) {
173
+ if (strstr(line+45, "continue"))
174
+ return 2;
175
+ return 1;
176
+ }
177
+ }
178
+ die("git fetch_pack: expected ACK/NAK, got '%s'", line);
179
+}
180
+
181
static int find_common(int fd[2], unsigned char *result_sha1,
182
struct ref *refs)
183
{
cache.h
-1
@@ -856,7 +856,6 @@ extern struct ref *find_ref_by_name(const struct ref *list, const char *name);
856
extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
857
extern int finish_connect(struct child_process *conn);
858
extern int path_match(const char *path, int nr, char **match);
859
-extern int get_ack(int fd, unsigned char *result_sha1);
859
struct extra_have_objects {
860
int nr, alloc;
861
unsigned char (*array)[20];
connect.c
-21
@@ -107,27 +107,6 @@ int server_supports(const char *feature)
107
strstr(server_capabilities, feature) != NULL;
108
}
109
110
-int get_ack(int fd, unsigned char *result_sha1)
111
-{
112
- static char line[1000];
113
- int len = packet_read_line(fd, line, sizeof(line));
114
-
115
- if (!len)
116
- die("git fetch-pack: expected ACK/NAK, got EOF");
117
- if (line[len-1] == '\n')
118
- line[--len] = 0;
119
- if (!strcmp(line, "NAK"))
120
- return 0;
121
- if (!prefixcmp(line, "ACK ")) {
122
- if (!get_sha1_hex(line+4, result_sha1)) {
123
- if (strstr(line+45, "continue"))
124
- return 2;
125
- return 1;
126
- }
127
- }
128
- die("git fetch_pack: expected ACK/NAK, got '%s'", line);
129
-}
130
-
110
int path_match(const char *path, int nr, char **match)
111
{
112
int i;