Skip to content

Commit 0e3c339

Browse files
committed
receive-pack: parse feature request a bit earlier
Ideally, we should have also allowed the first "shallow" to carry the feature request trailer, but that is water under the bridge now. This makes the next step to factor out the queuing of commands easier to review. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3bfcb95 commit 0e3c339

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

builtin/receive-pack.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ static struct command *read_head_info(struct sha1_array *shallow)
840840
unsigned char old_sha1[20], new_sha1[20];
841841
struct command *cmd;
842842
char *refname;
843-
int len, reflen;
843+
int len, reflen, linelen;
844844

845845
line = packet_read_line(0, &len);
846846
if (!line)
@@ -853,7 +853,18 @@ static struct command *read_head_info(struct sha1_array *shallow)
853853
continue;
854854
}
855855

856-
if (len < 83 ||
856+
linelen = strlen(line);
857+
if (linelen < len) {
858+
const char *feature_list = line + linelen + 1;
859+
if (parse_feature_request(feature_list, "report-status"))
860+
report_status = 1;
861+
if (parse_feature_request(feature_list, "side-band-64k"))
862+
use_sideband = LARGE_PACKET_MAX;
863+
if (parse_feature_request(feature_list, "quiet"))
864+
quiet = 1;
865+
}
866+
867+
if (linelen < 83 ||
857868
line[40] != ' ' ||
858869
line[81] != ' ' ||
859870
get_sha1_hex(line, old_sha1) ||
@@ -862,16 +873,7 @@ static struct command *read_head_info(struct sha1_array *shallow)
862873
line);
863874

864875
refname = line + 82;
865-
reflen = strlen(refname);
866-
if (reflen + 82 < len) {
867-
const char *feature_list = refname + reflen + 1;
868-
if (parse_feature_request(feature_list, "report-status"))
869-
report_status = 1;
870-
if (parse_feature_request(feature_list, "side-band-64k"))
871-
use_sideband = LARGE_PACKET_MAX;
872-
if (parse_feature_request(feature_list, "quiet"))
873-
quiet = 1;
874-
}
876+
reflen = linelen - 82;
875877
cmd = xcalloc(1, sizeof(struct command) + reflen + 1);
876878
hashcpy(cmd->old_sha1, old_sha1);
877879
hashcpy(cmd->new_sha1, new_sha1);

0 commit comments

Comments
 (0)