diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-09-04 12:13:32 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-09-15 13:23:19 -0700 |
commit | 52d2ae582e84c6d4ace8ab7e021808915148816a (patch) | |
tree | 2a4e7142a4970bccf8985e17d96cf62f672b897f /builtin/receive-pack.c | |
parent | send-pack: factor out capability string generation (diff) | |
download | tgif-52d2ae582e84c6d4ace8ab7e021808915148816a.tar.xz |
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>
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r-- | builtin/receive-pack.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 587f7da559..cbbad5488a 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -137,15 +137,21 @@ static void show_ref(const char *path, const unsigned char *sha1) if (ref_is_hidden(path)) return; - if (sent_capabilities) + if (sent_capabilities) { packet_write(1, "%s %s\n", sha1_to_hex(sha1), path); - else - packet_write(1, "%s %s%c%s%s agent=%s\n", - sha1_to_hex(sha1), path, 0, - " report-status delete-refs side-band-64k quiet", - prefer_ofs_delta ? " ofs-delta" : "", - git_user_agent_sanitized()); - sent_capabilities = 1; + } else { + struct strbuf cap = STRBUF_INIT; + + strbuf_addstr(&cap, + "report-status delete-refs side-band-64k quiet"); + if (prefer_ofs_delta) + 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) |