Skip to contentSkip to conversation

fetch-pack: Add missing line-feed character when sending depth-request packet line

PATCH In review Stan Hu 2 participants 2 messages Jun 16, 2016

lore
Share & tools
lore

Stan Hu

author
#0 lore raw

PATCH 1/1 fetch-pack: Add missing line-feed character when sending depth-request packet line

The pkt-line format mandates: "a sender should include a LF, but the receive MUST NOT complain if it is not present." This patch is not absolutely necessary since receivers handle the missing the LF, but this patch adds it for good measure.

---
 fetch-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fetch-pack.c +1 -1
index f96f6df..77299d9 100644
@@ -330,7 +330,7 @@ static int find_common(struct fetch_pack_args *args,
 	if (is_repository_shallow())
 		write_shallow_commits(&req_buf, 1, NULL);
 	if (args->depth > 0)
-		packet_buf_write(&req_buf, "deepen %d", args->depth);
+		packet_buf_write(&req_buf, "deepen %d\n", args->depth);
 	packet_buf_flush(&req_buf);
 	state_len = req_buf.len;
 
Signature · 1 line
2.7.3
#1 lore raw
Quoted 4 lines · Stan Hu

The pkt-line format mandates: "a sender should include a LF, but the receive MUST NOT complain if it is not present." This patch is not absolutely necessary since receivers handle the missing the LF, but this patch adds it for good measure.

s/since receivers handle/since receivers are expected to handle/;

Have you checked various re-implementations of upload-pack to see which one will break with this change, and made them aware about their non-compliance?

Quoted 18 lines
---
 fetch-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fetch-pack.c +1 -1
index f96f6df..77299d9 100644
@@ -330,7 +330,7 @@ static int find_common(struct fetch_pack_args *args,
 	if (is_repository_shallow())
 		write_shallow_commits(&req_buf, 1, NULL);
 	if (args->depth > 0)
-		packet_buf_write(&req_buf, "deepen %d", args->depth);
+		packet_buf_write(&req_buf, "deepen %d\n", args->depth);
 	packet_buf_flush(&req_buf);
 	state_len = req_buf.len;