fetch-pack: remove --keep-auto and make it the default.
This makes git-fetch over git native protocol to automatically decide to keep the downloaded pack if the fetch results in more than 100 objects, just like receive-pack invoked by git-push does. This logic is disabled when --keep is explicitly given from the command line, so that a very small clone still keeps the downloaded pack as before. The 100 threshold can be adjusted with fetch.unpacklimit configuration. We might want to introduce transfer.unpacklimit to consolidate the two unpacklimit variables, which will be a topic for the next patch. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
9e10fd1ac0
commit
af7cf268f0
@ -295,6 +295,16 @@ diff.renames::
|
|||||||
will enable basic rename detection. If set to "copies" or
|
will enable basic rename detection. If set to "copies" or
|
||||||
"copy", it will detect copies, as well.
|
"copy", it will detect copies, as well.
|
||||||
|
|
||||||
|
fetch.unpackLimit::
|
||||||
|
If the number of objects fetched over the git native
|
||||||
|
transfer is below this
|
||||||
|
limit, then the objects will be unpacked into loose object
|
||||||
|
files. However if the number of received objects equals or
|
||||||
|
exceeds this limit then the received pack will be stored as
|
||||||
|
a pack, after adding any missing delta bases. Storing the
|
||||||
|
pack from a push can make the push operation complete faster,
|
||||||
|
especially on slow filesystems.
|
||||||
|
|
||||||
format.headers::
|
format.headers::
|
||||||
Additional email headers to include in a patch to be submitted
|
Additional email headers to include in a patch to be submitted
|
||||||
by mail. See gitlink:git-format-patch[1].
|
by mail. See gitlink:git-format-patch[1].
|
||||||
|
31
fetch-pack.c
31
fetch-pack.c
@ -8,7 +8,7 @@
|
|||||||
#include "sideband.h"
|
#include "sideband.h"
|
||||||
|
|
||||||
static int keep_pack;
|
static int keep_pack;
|
||||||
static int keep_auto;
|
static int unpack_limit = 100;
|
||||||
static int quiet;
|
static int quiet;
|
||||||
static int verbose;
|
static int verbose;
|
||||||
static int fetch_all;
|
static int fetch_all;
|
||||||
@ -503,14 +503,14 @@ static int get_pack(int xd[2])
|
|||||||
|
|
||||||
av = argv;
|
av = argv;
|
||||||
*hdr_arg = 0;
|
*hdr_arg = 0;
|
||||||
if (keep_auto) {
|
if (unpack_limit) {
|
||||||
struct pack_header header;
|
struct pack_header header;
|
||||||
|
|
||||||
if (read_pack_header(fd[0], &header))
|
if (read_pack_header(fd[0], &header))
|
||||||
die("protocol error: bad pack header");
|
die("protocol error: bad pack header");
|
||||||
snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u",
|
snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u",
|
||||||
ntohl(header.hdr_version), ntohl(header.hdr_entries));
|
ntohl(header.hdr_version), ntohl(header.hdr_entries));
|
||||||
if (ntohl(header.hdr_entries) < keep_auto)
|
if (ntohl(header.hdr_entries) < unpack_limit)
|
||||||
do_keep = 0;
|
do_keep = 0;
|
||||||
else
|
else
|
||||||
do_keep = 1;
|
do_keep = 1;
|
||||||
@ -523,7 +523,7 @@ static int get_pack(int xd[2])
|
|||||||
*av++ = "-v";
|
*av++ = "-v";
|
||||||
if (use_thin_pack)
|
if (use_thin_pack)
|
||||||
*av++ = "--fix-thin";
|
*av++ = "--fix-thin";
|
||||||
if (keep_pack > 1 || keep_auto) {
|
if (keep_pack > 1 || unpack_limit) {
|
||||||
int s = sprintf(keep_arg,
|
int s = sprintf(keep_arg,
|
||||||
"--keep=fetch-pack %d on ", getpid());
|
"--keep=fetch-pack %d on ", getpid());
|
||||||
if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
|
if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
|
||||||
@ -642,6 +642,16 @@ static int remove_duplicates(int nr_heads, char **heads)
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int fetch_pack_config(const char *var, const char *value)
|
||||||
|
{
|
||||||
|
if (strcmp(var, "fetch.unpacklimit") == 0) {
|
||||||
|
unpack_limit = git_config_int(var, value);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return git_default_config(var, value);
|
||||||
|
}
|
||||||
|
|
||||||
static struct lock_file lock;
|
static struct lock_file lock;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
@ -653,6 +663,8 @@ int main(int argc, char **argv)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
setup_git_directory();
|
setup_git_directory();
|
||||||
|
setup_ident();
|
||||||
|
git_config(fetch_pack_config);
|
||||||
|
|
||||||
nr_heads = 0;
|
nr_heads = 0;
|
||||||
heads = NULL;
|
heads = NULL;
|
||||||
@ -674,16 +686,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (!strcmp("--keep", arg) || !strcmp("-k", arg)) {
|
if (!strcmp("--keep", arg) || !strcmp("-k", arg)) {
|
||||||
keep_pack++;
|
keep_pack++;
|
||||||
continue;
|
unpack_limit = 0;
|
||||||
}
|
|
||||||
if (!strcmp("--keep-auto", arg)) {
|
|
||||||
keep_auto = 100;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!strncmp("--keep-auto=", arg, 12)) {
|
|
||||||
keep_auto = strtoul(arg + 12, NULL, 0);
|
|
||||||
if (keep_auto < 20)
|
|
||||||
keep_auto = 20;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp("--thin", arg)) {
|
if (!strcmp("--thin", arg)) {
|
||||||
|
@ -97,7 +97,8 @@ pull_to_client () {
|
|||||||
(
|
(
|
||||||
mkdir client &&
|
mkdir client &&
|
||||||
cd client &&
|
cd client &&
|
||||||
git-init 2>> log2.txt
|
git-init 2>> log2.txt &&
|
||||||
|
git repo-config fetch.unpacklimit 0
|
||||||
)
|
)
|
||||||
|
|
||||||
add A1
|
add A1
|
||||||
|
Loading…
Reference in New Issue
Block a user