Subject: [PATCH 07/10] receive-pack: request for packv4 if it's the preferred version

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Thu, 26 Sep 2013 09:26:46 +0700

This is the only plumbing command that is controlled by
core.preferredPackVersion so far.

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 Documentation/technical/protocol-capabilities.txt | 4 ++++
 builtin/receive-pack.c                            | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/technical/protocol-capabilities.txt b/Documentation/technical/protocol-capabilities.txt
index be09792..32153cd 100644
--- a/Documentation/technical/protocol-capabilities.txt
+++ b/Documentation/technical/protocol-capabilities.txt
@@ -226,4 +226,8 @@ this capability, the server may send a pack version 4. The server can
 choose to send pack version 2 even if the client accepts this
 capability.
 
+The receive-pack server advertises this capability if it wants to
+receive the pack in format version 4 and the client should send in
+this format.
+
 This capability does not include multi-base tree support.
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index e3eb5fc..288b0bc 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -130,10 +130,11 @@ static void show_ref(const char *path, const unsigned char *sha1)
 	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",
+		packet_write(1, "%s %s%c%s%s%s agent=%s\n",
 			     sha1_to_hex(sha1), path, 0,
 			     " report-status delete-refs side-band-64k quiet",
 			     prefer_ofs_delta ? " ofs-delta" : "",
+			     core_default_pack_version == 4 ? " packv4" : "",
 			     git_user_agent_sanitized());
 	sent_capabilities = 1;
 }
-- 
1.8.2.82.gc24b958