Ensure builtin-fetch honors {fetch,transfer}.unpackLimit
The only way to configure the unpacking limit is currently through the .git/config (or ~/.gitconfig) mechanism as we have no existing command line option interface to control this threshold on a per invocation basis. This was intentional by design as the storage policy of the repository should be a repository-wide decision and should not be subject to variations made on individual command executions. Earlier builtin-fetch was bypassing the unpacking limit chosen by the user through the configuration file as it did not reread the configuration options through fetch_pack_config if we called the internal fetch_pack() API directly. We now ensure we always run the config file through fetch_pack_config at least once in this process, thereby setting our unpackLimit properly. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
fa74052922
commit
50ab5fd3fc
@ -670,19 +670,25 @@ static int fetch_pack_config(const char *var, const char *value)
|
|||||||
|
|
||||||
static struct lock_file lock;
|
static struct lock_file lock;
|
||||||
|
|
||||||
|
static void fetch_pack_setup(void)
|
||||||
|
{
|
||||||
|
static int did_setup;
|
||||||
|
if (did_setup)
|
||||||
|
return;
|
||||||
|
git_config(fetch_pack_config);
|
||||||
|
if (0 <= transfer_unpack_limit)
|
||||||
|
unpack_limit = transfer_unpack_limit;
|
||||||
|
else if (0 <= fetch_unpack_limit)
|
||||||
|
unpack_limit = fetch_unpack_limit;
|
||||||
|
did_setup = 1;
|
||||||
|
}
|
||||||
|
|
||||||
int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
|
int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
int i, ret, nr_heads;
|
int i, ret, nr_heads;
|
||||||
struct ref *ref;
|
struct ref *ref;
|
||||||
char *dest = NULL, **heads;
|
char *dest = NULL, **heads;
|
||||||
|
|
||||||
git_config(fetch_pack_config);
|
|
||||||
|
|
||||||
if (0 <= transfer_unpack_limit)
|
|
||||||
unpack_limit = transfer_unpack_limit;
|
|
||||||
else if (0 <= fetch_unpack_limit)
|
|
||||||
unpack_limit = fetch_unpack_limit;
|
|
||||||
|
|
||||||
nr_heads = 0;
|
nr_heads = 0;
|
||||||
heads = NULL;
|
heads = NULL;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
@ -760,6 +766,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
|
|||||||
struct ref *ref;
|
struct ref *ref;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
fetch_pack_setup();
|
||||||
memcpy(&args, my_args, sizeof(args));
|
memcpy(&args, my_args, sizeof(args));
|
||||||
if (args.depth > 0) {
|
if (args.depth > 0) {
|
||||||
if (stat(git_path("shallow"), &st))
|
if (stat(git_path("shallow"), &st))
|
||||||
|
@ -242,11 +242,7 @@ static int close_bundle(struct transport *transport)
|
|||||||
struct git_transport_data {
|
struct git_transport_data {
|
||||||
unsigned thin : 1;
|
unsigned thin : 1;
|
||||||
unsigned keep : 1;
|
unsigned keep : 1;
|
||||||
|
|
||||||
int unpacklimit;
|
|
||||||
|
|
||||||
int depth;
|
int depth;
|
||||||
|
|
||||||
const char *uploadpack;
|
const char *uploadpack;
|
||||||
const char *receivepack;
|
const char *receivepack;
|
||||||
};
|
};
|
||||||
@ -267,9 +263,6 @@ static int set_git_option(struct transport *connection,
|
|||||||
} else if (!strcmp(name, TRANS_OPT_KEEP)) {
|
} else if (!strcmp(name, TRANS_OPT_KEEP)) {
|
||||||
data->keep = !!value;
|
data->keep = !!value;
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!strcmp(name, TRANS_OPT_UNPACKLIMIT)) {
|
|
||||||
data->unpacklimit = atoi(value);
|
|
||||||
return 0;
|
|
||||||
} else if (!strcmp(name, TRANS_OPT_DEPTH)) {
|
} else if (!strcmp(name, TRANS_OPT_DEPTH)) {
|
||||||
if (!value)
|
if (!value)
|
||||||
data->depth = 0;
|
data->depth = 0;
|
||||||
@ -318,7 +311,6 @@ static int fetch_refs_via_pack(struct transport *transport,
|
|||||||
args.uploadpack = data->uploadpack;
|
args.uploadpack = data->uploadpack;
|
||||||
args.keep_pack = data->keep;
|
args.keep_pack = data->keep;
|
||||||
args.lock_pack = 1;
|
args.lock_pack = 1;
|
||||||
args.unpacklimit = data->unpacklimit;
|
|
||||||
args.use_thin_pack = data->thin;
|
args.use_thin_pack = data->thin;
|
||||||
args.verbose = transport->verbose;
|
args.verbose = transport->verbose;
|
||||||
args.depth = data->depth;
|
args.depth = data->depth;
|
||||||
@ -435,7 +427,6 @@ struct transport *transport_get(struct remote *remote, const char *url)
|
|||||||
data->receivepack = "git-receive-pack";
|
data->receivepack = "git-receive-pack";
|
||||||
if (remote && remote->receivepack)
|
if (remote && remote->receivepack)
|
||||||
data->receivepack = remote->receivepack;
|
data->receivepack = remote->receivepack;
|
||||||
data->unpacklimit = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -47,9 +47,6 @@ struct transport *transport_get(struct remote *, const char *);
|
|||||||
/* Keep the pack that was transferred if not null */
|
/* Keep the pack that was transferred if not null */
|
||||||
#define TRANS_OPT_KEEP "keep"
|
#define TRANS_OPT_KEEP "keep"
|
||||||
|
|
||||||
/* Unpack the objects if fewer than this number of objects are fetched */
|
|
||||||
#define TRANS_OPT_UNPACKLIMIT "unpacklimit"
|
|
||||||
|
|
||||||
/* Limit the depth of the fetch if not null */
|
/* Limit the depth of the fetch if not null */
|
||||||
#define TRANS_OPT_DEPTH "depth"
|
#define TRANS_OPT_DEPTH "depth"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user