Skip to content

Commit

Permalink
Move "get_ack()" to common git_connect functions
Browse files Browse the repository at this point in the history
git-clone-pack will want it too. Soon.
  • Loading branch information
Linus Torvalds committed Jul 5, 2005
1 parent 4f7770c commit 41cb748
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
19 changes: 19 additions & 0 deletions connect.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
18 changes: 0 additions & 18 deletions fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 41cb748

Please sign in to comment.