push: respect --no-thin

- From the beginning of push.c in 755225d, 2006-04-29, "thin" option was enabled by default but could be turned off with --no-thin. - Then Shawn changed the default to 0 in favor of saving server resources in a4503a1, 2007-09-09. --no-thin worked great. - One day later, in 9b28851 Daniel extracted some code from push.c to create transport.c. He (probably accidentally) flipped the default value from 0 to 1 in transport_get(). From then on --no-thin is effectively no-op because git-push still expects the default value to be false and only calls transport_set_option() when "thin" variable in push.c is true (which is unnecessary). Correct the code to respect --no-thin by calling transport_set_option() in both cases. receive-pack learns about --reject-thin-pack-for-testing option, which only is for testing purposes, hence no document update. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Aug 12, 2013 at 20:55 UTC f7c815c3eede201def87a643fdcad09a9af3e3e7
3 files changed +26 -4
builtin/push.c
+2 -3
@@ -15,7 +15,7 @@ static const char * const push_usage[] = {
15 NULL,
16 };
17
18 -static int thin;
18 +static int thin = 1;
19 static int deleterefs;
20 static const char *receivepack;
21 static int verbosity;
@@ -313,8 +313,7 @@ static int push_with_options(struct transport *transport, int flags)
313 if (receivepack)
314 transport_set_option(transport,
315 TRANS_OPT_RECEIVEPACK, receivepack);
316 - if (thin)
317 - transport_set_option(transport, TRANS_OPT_THIN, "yes");
316 + transport_set_option(transport, TRANS_OPT_THIN, thin ? "yes" : NULL);
317
318 if (verbosity > 0)
319 fprintf(stderr, _("Pushing to %s\n"), transport->url);
builtin/receive-pack.c
+7 -1
@@ -38,6 +38,7 @@ static int quiet;
38 static int prefer_ofs_delta = 1;
39 static int auto_update_server_info;
40 static int auto_gc = 1;
41 +static int fix_thin = 1;
42 static const char *head_name;
43 static void *head_name_to_free;
44 static int sent_capabilities;
@@ -869,7 +870,8 @@ static const char *unpack(int err_fd)
870 keeper[i++] = "--stdin";
871 if (fsck_objects)
872 keeper[i++] = "--strict";
872 - keeper[i++] = "--fix-thin";
873 + if (fix_thin)
874 + keeper[i++] = "--fix-thin";
875 keeper[i++] = hdr_arg;
876 keeper[i++] = keep_arg;
877 keeper[i++] = NULL;
@@ -975,6 +977,10 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
977 stateless_rpc = 1;
978 continue;
979 }
980 + if (!strcmp(arg, "--reject-thin-pack-for-testing")) {
981 + fix_thin = 0;
982 + continue;
983 + }
984
985 usage(receive_pack_usage);
986 }
t/t5516-fetch-push.sh
+17
@@ -1172,4 +1172,21 @@ test_expect_success 'push --follow-tag only pushes relevant tags' '
1172 test_cmp expect actual
1173 '
1174
1175 +test_expect_success 'push --no-thin must produce non-thin pack' '
1176 + cat >>path1 <<\EOF &&
1177 +keep base version of path1 big enough, compared to the new changes
1178 +later, in order to pass size heuristics in
1179 +builtin/pack-objects.c:try_delta()
1180 +EOF
1181 + git commit -am initial &&
1182 + git init no-thin &&
1183 + git --git-dir=no-thin/.git config receive.unpacklimit 0 &&
1184 + git push no-thin/.git refs/heads/master:refs/heads/foo &&
1185 + echo modified >> path1 &&
1186 + git commit -am modified &&
1187 + git repack -adf &&
1188 + rcvpck="git receive-pack --reject-thin-pack-for-testing" &&
1189 + git push --no-thin --receive-pack="$rcvpck" no-thin/.git refs/heads/master:refs/heads/foo
1190 +'
1191 +
1192 test_done