зеркало из https://github.com/microsoft/git.git
upload-pack: minor clean-up in multi-ack logic
No changes to what it does, but separating the codepath clearly with if ... else if ... chain makes it easier to follow. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
182a8dabd5
Коммит
c04c4e5708
|
@ -351,7 +351,8 @@ static int got_sha1(char *hex, unsigned char *sha1)
|
||||||
static int get_common_commits(void)
|
static int get_common_commits(void)
|
||||||
{
|
{
|
||||||
static char line[1000];
|
static char line[1000];
|
||||||
unsigned char sha1[20], last_sha1[20];
|
unsigned char sha1[20];
|
||||||
|
char hex[41], last_hex[41];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
track_object_refs = 0;
|
track_object_refs = 0;
|
||||||
|
@ -368,21 +369,22 @@ static int get_common_commits(void)
|
||||||
}
|
}
|
||||||
len = strip(line, len);
|
len = strip(line, len);
|
||||||
if (!strncmp(line, "have ", 5)) {
|
if (!strncmp(line, "have ", 5)) {
|
||||||
if (got_sha1(line+5, sha1) &&
|
if (got_sha1(line+5, sha1)) {
|
||||||
(multi_ack || have_obj.nr == 1)) {
|
memcpy(hex, sha1_to_hex(sha1), 41);
|
||||||
packet_write(1, "ACK %s%s\n",
|
if (multi_ack) {
|
||||||
sha1_to_hex(sha1),
|
const char *msg = "ACK %s continue\n";
|
||||||
multi_ack ? " continue" : "");
|
packet_write(1, msg, hex);
|
||||||
if (multi_ack)
|
memcpy(last_hex, hex, 41);
|
||||||
memcpy(last_sha1, sha1, 20);
|
}
|
||||||
|
else if (have_obj.nr == 1)
|
||||||
|
packet_write(1, "ACK %s\n", hex);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(line, "done")) {
|
if (!strcmp(line, "done")) {
|
||||||
if (have_obj.nr > 0) {
|
if (have_obj.nr > 0) {
|
||||||
if (multi_ack)
|
if (multi_ack)
|
||||||
packet_write(1, "ACK %s\n",
|
packet_write(1, "ACK %s\n", last_hex);
|
||||||
sha1_to_hex(last_sha1));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
packet_write(1, "NAK\n");
|
packet_write(1, "NAK\n");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче