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

[PATCH v3] push: respect --no-thin

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 11, 2013, 08:52 UTC
Message-ID
<1376211178-17444-1-git-send-email-pclouds@gmail.com>
In-Reply-To
<1376184258-6784-1-git-send-email-pclouds@gmail.com>

Over the time the default value for --thin has been switched between on and off. As of now it's always on, even if --no-thin is given. Correct the code to respect --no-thin.

receive-pack learns about --no-thin only for testing purposes, hence no document update.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 v3 gets rid of seq in the test.
 builtin/push.c         |  5 ++---
 builtin/receive-pack.c |  8 +++++++-
 t/t5516-fetch-push.sh  | 16 ++++++++++++++++
 3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index 04f0eaf..333a1fb 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -15,7 +15,7 @@ static const char * const push_usage[] = {
 	NULL,
 };
 
-static int thin;
+static int thin = 1;
 static int deleterefs;
 static const char *receivepack;
 static int verbosity;
@@ -313,8 +313,7 @@ static int push_with_options(struct transport *transport, int flags)
 	if (receivepack)
 		transport_set_option(transport,
 				     TRANS_OPT_RECEIVEPACK, receivepack);
-	if (thin)
-		transport_set_option(transport, TRANS_OPT_THIN, "yes");
+	transport_set_option(transport, TRANS_OPT_THIN, thin ? "yes" : NULL);
 
 	if (verbosity > 0)
 		fprintf(stderr, _("Pushing to %s\n"), transport->url);
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index e3eb5fc..da60817 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -38,6 +38,7 @@ static int quiet;
 static int prefer_ofs_delta = 1;
 static int auto_update_server_info;
 static int auto_gc = 1;
+static int fix_thin = 1;
 static const char *head_name;
 static void *head_name_to_free;
 static int sent_capabilities;
@@ -869,7 +870,8 @@ static const char *unpack(int err_fd)
 		keeper[i++] = "--stdin";
 		if (fsck_objects)
 			keeper[i++] = "--strict";
-		keeper[i++] = "--fix-thin";
+		if (fix_thin)
+			keeper[i++] = "--fix-thin";
 		keeper[i++] = hdr_arg;
 		keeper[i++] = keep_arg;
 		keeper[i++] = NULL;
@@ -975,6 +977,10 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 				stateless_rpc = 1;
 				continue;
 			}
+			if (!strcmp(arg, "--no-thin")) {
+				fix_thin = 0;
+				continue;
+			}
 
 			usage(receive_pack_usage);
 		}
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 4691d51..3cfd1cd 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1172,4 +1172,20 @@ test_expect_success 'push --follow-tag only pushes relevant tags' '
 	test_cmp expect actual
 '
 
+test_expect_success 'push --no-thin must produce non-thin pack' '
+	cat >>path1 <<\EOF &&
+keep base version of path1 big enough, compared to the new changes
+later, in order to pass size heuristics in
+builtin/pack-objects.c:try_delta()
+EOF
+	git commit -am initial &&
+	git init no-thin &&
+	git --git-dir=no-thin/.git config receive.unpacklimit 0 &&
+	git push no-thin/.git refs/heads/master:refs/heads/foo &&
+	echo modified >> path1 &&
+	git commit -am modified &&
+	git repack -adf &&
+	git push --no-thin --receive-pack="git receive-pack --no-thin" no-thin/.git refs/heads/master:refs/heads/foo
+'
+
 test_done
-- 
1.8.2.83.gc99314b
Previous: Eric SunshineNext: Junio C Hamano
Message 6 of 10 in “push: respect --no-thin”
  1. push: respect --no-thinNguyễn Thái Ngọc Duy, Aug 10, 2013
  2. Jeff KingAug 10, 2013
  3. Duy NguyenAug 10, 2013
  4. push: respect --no-thinNguyễn Thái Ngọc Duy, Aug 11, 2013
  5. Eric SunshineAug 11, 2013
  6. push: respect --no-thinNguyễn Thái Ngọc Duy, Aug 11, 2013
  7. Junio C HamanoAug 12, 2013
  8. Duy NguyenAug 12, 2013
  9. Junio C HamanoAug 13, 2013
  10. push: respect --no-thinNguyễn Thái Ngọc Duy, Aug 12, 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.