git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 08/10] send-pack: support pack v4

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Sep 26, 2013, 02:26 UTC
Message-ID
<1380162409-18224-9-git-send-email-pclouds@gmail.com>
In-Reply-To
<1380162409-18224-1-git-send-email-pclouds@gmail.com>

Contrary to the fetch direction, whether send-pack sends packv4 is totally controlled by the server. This is in favor of lowering load at the server side. More logic may be added later to allow the client to stick to v2 even if the server requests v4.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 send-pack.c           |  5 +++++
 send-pack.h           |  1 +
 t/t5516-fetch-push.sh | 12 ++++++++++++
 3 files changed, 18 insertions(+)
diff --git a/send-pack.c b/send-pack.c
index 7d172ef..977c14b 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -44,6 +44,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
 		NULL,
 		NULL,
 		NULL,
+		NULL,
 	};
 	struct child_process po;
 	int i;
@@ -57,6 +58,8 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
 		argv[i++] = "-q";
 	if (args->progress)
 		argv[i++] = "--progress";
+	if (args->packv4)
+		argv[i++] = "--version=4";
 	memset(&po, 0, sizeof(po));
 	po.argv = argv;
 	po.in = -1;
@@ -205,6 +208,8 @@ int send_pack(struct send_pack_args *args,
 		quiet_supported = 1;
 	if (server_supports("agent"))
 		agent_supported = 1;
+	if (server_supports("packv4"))
+		args->packv4 = 1;
 
 	if (!remote_refs) {
 		fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
diff --git a/send-pack.h b/send-pack.h
index 05d7ab1..cda770c 100644
--- a/send-pack.h
+++ b/send-pack.h
@@ -11,6 +11,7 @@ struct send_pack_args {
 		use_thin_pack:1,
 		use_ofs_delta:1,
 		dry_run:1,
+		packv4:1,
 		stateless_rpc:1;
 };
 
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 4691d51..d0c116f 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1172,4 +1172,16 @@ test_expect_success 'push --follow-tag only pushes relevant tags' '
 	test_cmp expect actual
 '
 
+test_expect_success 'push pack v4' '
+	git init pv4 &&
+	git --git-dir pv4/.git config core.preferredPackVersion 4 &&
+	git --git-dir pv4/.git config transfer.unpackLimit 1 &&
+	git push pv4 HEAD:refs/heads/head &&
+	P=`ls pv4/.git/objects/pack/pack-*.pack` &&
+	# Offset 4 is pack version
+	test-dump ntohl "$P" 4 >ver.actual &&
+	echo 4 >ver.expected &&
+	test_cmp ver.expected ver.actual
+'
+
 test_done
-- 
1.8.2.82.gc24b958
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 10 of 20 in “pack v4 UI support”
  1. 00/10 pack v4 UI supportNguyễn Thái Ngọc Duy, Sep 26, 2013
  2. 01/10 test-dump: new test program to examine binary dataNguyễn Thái Ngọc Duy, Sep 26, 2013
  3. 02/10 config: add core.preferredPackVersionNguyễn Thái Ngọc Duy, Sep 26, 2013
  4. 03/10 upload-pack: new capability to send pack v4Nguyễn Thái Ngọc Duy, Sep 26, 2013
  5. 04/10 fetch: new option to set preferred pack version for transferNguyễn Thái Ngọc Duy, Sep 26, 2013
  6. 05/10 clone: new option to set preferred pack version for transferNguyễn Thái Ngọc Duy, Sep 26, 2013
  7. 06/10 fetch: pack v4 support on smart httpNguyễn Thái Ngọc Duy, Sep 26, 2013
  8. 07/10 receive-pack: request for packv4 if it's the preferred versionNguyễn Thái Ngọc Duy, Sep 26, 2013
  9. Junio C HamanoOct 17, 2013
  10. 08/10 send-pack: support pack v4Nguyễn Thái Ngọc Duy, Sep 26, 2013
  11. 09/10 repack: add --pack-version and fall back to core.preferredPackVersionNguyễn Thái Ngọc Duy, Sep 26, 2013
  12. repack: Add --version parameterStefan Beller, Sep 26, 2013
  13. Felipe ContrerasSep 26, 2013
  14. Stefan BellerSep 28, 2013
  15. Duy NguyenSep 26, 2013
  16. Stefan BellerSep 28, 2013
  17. 10/10 count-objects: report pack v4 usageNguyễn Thái Ngọc Duy, Sep 26, 2013
  18. Nicolas PitreSep 26, 2013
  19. Duy NguyenSep 26, 2013
  20. Nicolas PitreSep 27, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.