Re: [PATCH 3/7] pack-protocol.txt: Mark all LFs in push-cert as required

Subsystems: the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 3/7] pack-protocol.txt: Mark all LFs in push-cert as required

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:05:37

Junio C Hamano [off-list ref] writes:
quoted
I am moderately negative about this; wouldn't it make the end result
cleaner to fix the implementation?
I think that something like this should be sufficient.  As the
receiving end, we must not complain if there is no terminator.
...
And the change we are *not* going to make, but I made temporarily
only for testing, on the sending side to violate our "sender SHOULD
terminate with LF" rule would look like this:

There is a slight complication on sending an empty line without any
termination, though ;-)  The reader that calls packet_read() cannot
tell such a payload from a flush packet, I think.

*That* may be something we want to document.
diff --git a/send-pack.c b/send-pack.c
index 2a64fec..1a743db 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -273,9 +273,11 @@ static int generate_push_cert(struct strbuf *req_buf,
 
 	packet_buf_write(req_buf, "push-cert%c%s", 0, cap_string);
 	for (cp = cert.buf; cp < cert.buf + cert.len; cp = np) {
+		int len;
 		np = next_line(cp, cert.buf + cert.len - cp);
+		len = (np <= cp + 1) ? 1 : (np - cp - 1);
 		packet_buf_write(req_buf,
-				 "%.*s", (int)(np - cp), cp);
+				 "%.*s", len, cp);
 	}
 	packet_buf_write(req_buf, "push-cert-end\n");
 

Re: [PATCH 3/7] pack-protocol.txt: Mark all LFs in push-cert as required

From: Jeff King <hidden>
Date: 2016-06-15 23:05:37

On Wed, Jul 01, 2015 at 01:39:49PM -0700, Junio C Hamano wrote:
There is a slight complication on sending an empty line without any
termination, though ;-)  The reader that calls packet_read() cannot
tell such a payload from a flush packet, I think.

*That* may be something we want to document.
Usually flush packets are "0000", and an empty data packet
is "0004". Or are you talking about some kind of flush inside the
pkt-data stream?

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help