Skip to content

Commit

Permalink
push: respect --no-thin
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
pclouds authored and gitster committed Aug 13, 2013
1 parent 96cb27a commit f7c815c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
5 changes: 2 additions & 3 deletions builtin/push.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion builtin/receive-pack.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -975,6 +977,10 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
stateless_rpc = 1;
continue;
}
if (!strcmp(arg, "--reject-thin-pack-for-testing")) {
fix_thin = 0;
continue;
}

usage(receive_pack_usage);
}
Expand Down
17 changes: 17 additions & 0 deletions t/t5516-fetch-push.sh
Expand Up @@ -1172,4 +1172,21 @@ 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 &&
rcvpck="git receive-pack --reject-thin-pack-for-testing" &&
git push --no-thin --receive-pack="$rcvpck" no-thin/.git refs/heads/master:refs/heads/foo
'

test_done

0 comments on commit f7c815c

Please sign in to comment.