pack-protocol.txt does not list the nonce as optional. Fortunately, it
should be impossible to not have a nonce by this point in the code, as
the caller should have died on line 380 prior to generating a push
certificate with an empty nonce.

Nonetheless, having this explicit error handling in the code reduces
confusion for implementors trying to understand the signed push
protocol by looking at the reference implementation.

Signed-off-by: Dave Borowitz <dborow...@google.com>
---
 send-pack.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/send-pack.c b/send-pack.c
index 2a64fec..77e2131 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -254,6 +254,8 @@ static int generate_push_cert(struct strbuf *req_buf,
        }
        if (push_cert_nonce[0])
                strbuf_addf(&cert, "nonce %s\n", push_cert_nonce);
+       else
+               die(_("server did not provide a nonce"));
        strbuf_addstr(&cert, "\n");
 
        for (ref = remote_refs; ref; ref = ref->next) {
-- 
2.4.3.573.g4eafbef

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to