Skip to content

Commit f7c815c

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 96cb27a commit f7c815c

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

builtin/push.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static const char * const push_usage[] = {
1515
NULL,
1616
};
1717

18-
static int thin;
18+
static int thin = 1;
1919
static int deleterefs;
2020
static const char *receivepack;
2121
static int verbosity;
@@ -313,8 +313,7 @@ static int push_with_options(struct transport *transport, int flags)
313313
if (receivepack)
314314
transport_set_option(transport,
315315
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);
318317

319318
if (verbosity > 0)
320319
fprintf(stderr, _("Pushing to %s\n"), transport->url);

builtin/receive-pack.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static int quiet;
3838
static int prefer_ofs_delta = 1;
3939
static int auto_update_server_info;
4040
static int auto_gc = 1;
41+
static int fix_thin = 1;
4142
static const char *head_name;
4243
static void *head_name_to_free;
4344
static int sent_capabilities;
@@ -869,7 +870,8 @@ static const char *unpack(int err_fd)
869870
keeper[i++] = "--stdin";
870871
if (fsck_objects)
871872
keeper[i++] = "--strict";
872-
keeper[i++] = "--fix-thin";
873+
if (fix_thin)
874+
keeper[i++] = "--fix-thin";
873875
keeper[i++] = hdr_arg;
874876
keeper[i++] = keep_arg;
875877
keeper[i++] = NULL;
@@ -975,6 +977,10 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
975977
stateless_rpc = 1;
976978
continue;
977979
}
980+
if (!strcmp(arg, "--reject-thin-pack-for-testing")) {
981+
fix_thin = 0;
982+
continue;
983+
}
978984

979985
usage(receive_pack_usage);
980986
}

t/t5516-fetch-push.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,4 +1172,21 @@ test_expect_success 'push --follow-tag only pushes relevant tags' '
11721172
test_cmp expect actual
11731173
'
11741174

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+
11751192
test_done

0 commit comments

Comments
 (0)