receive-pack: factor out capability string generation
Similar to the previous one for send-pack, make it easier and cleaner to add to capability advertisement. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
887f3533fd
commit
52d2ae582e
@ -137,15 +137,21 @@ static void show_ref(const char *path, const unsigned char *sha1)
|
|||||||
if (ref_is_hidden(path))
|
if (ref_is_hidden(path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sent_capabilities)
|
if (sent_capabilities) {
|
||||||
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
|
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
|
||||||
else
|
} else {
|
||||||
packet_write(1, "%s %s%c%s%s agent=%s\n",
|
struct strbuf cap = STRBUF_INIT;
|
||||||
sha1_to_hex(sha1), path, 0,
|
|
||||||
" report-status delete-refs side-band-64k quiet",
|
strbuf_addstr(&cap,
|
||||||
prefer_ofs_delta ? " ofs-delta" : "",
|
"report-status delete-refs side-band-64k quiet");
|
||||||
git_user_agent_sanitized());
|
if (prefer_ofs_delta)
|
||||||
sent_capabilities = 1;
|
strbuf_addstr(&cap, " ofs-delta");
|
||||||
|
strbuf_addf(&cap, " agent=%s", git_user_agent_sanitized());
|
||||||
|
packet_write(1, "%s %s%c%s\n",
|
||||||
|
sha1_to_hex(sha1), path, 0, cap.buf);
|
||||||
|
strbuf_release(&cap);
|
||||||
|
sent_capabilities = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, void *unused)
|
static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, void *unused)
|
||||||
|
Loading…
Reference in New Issue
Block a user