Skip to content

Commit 28754ab

Browse files
spearcegitster
authored andcommitted
Move "get_ack()" back to fetch-pack
In 41cb748 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 efc7fa5. 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent edace6f commit 28754ab

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

builtin-fetch-pack.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,27 @@ static const unsigned char *get_rev(void)
157157
return commit->object.sha1;
158158
}
159159

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+
160181
static int find_common(int fd[2], unsigned char *result_sha1,
161182
struct ref *refs)
162183
{

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ extern struct ref *find_ref_by_name(const struct ref *list, const char *name);
856856
extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
857857
extern int finish_connect(struct child_process *conn);
858858
extern int path_match(const char *path, int nr, char **match);
859-
extern int get_ack(int fd, unsigned char *result_sha1);
860859
struct extra_have_objects {
861860
int nr, alloc;
862861
unsigned char (*array)[20];

connect.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,27 +107,6 @@ int server_supports(const char *feature)
107107
strstr(server_capabilities, feature) != NULL;
108108
}
109109

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-
131110
int path_match(const char *path, int nr, char **match)
132111
{
133112
int i;

0 commit comments

Comments
 (0)