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>
Junio C Hamano committed
Jan 24, 2007 at 16:47 UTC
af7cf268f0bf8d4216f9c11d1cb0082cb3550f61
3 files changed
+29
-15
Documentation/config.txt
+10
@@ -295,6 +295,16 @@ diff.renames::
295
will enable basic rename detection. If set to "copies" or
296
"copy", it will detect copies, as well.
297
298
+fetch.unpackLimit::
299
+ If the number of objects fetched over the git native
300
+ transfer is below this
301
+ limit, then the objects will be unpacked into loose object
302
+ files. However if the number of received objects equals or
303
+ exceeds this limit then the received pack will be stored as
304
+ a pack, after adding any missing delta bases. Storing the
305
+ pack from a push can make the push operation complete faster,
306
+ especially on slow filesystems.
307
+
308
format.headers::
309
Additional email headers to include in a patch to be submitted
310
by mail. See gitlink:git-format-patch[1].
fetch-pack.c
+17
-14
@@ -8,7 +8,7 @@
8
#include "sideband.h"
9
10
static int keep_pack;
11
-static int keep_auto;
11
+static int unpack_limit = 100;
12
static int quiet;
13
static int verbose;
14
static int fetch_all;
@@ -503,14 +503,14 @@ static int get_pack(int xd[2])
503
504
av = argv;
505
*hdr_arg = 0;
506
- if (keep_auto) {
506
+ if (unpack_limit) {
507
struct pack_header header;
508
509
if (read_pack_header(fd[0], &header))
510
die("protocol error: bad pack header");
511
snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u",
512
ntohl(header.hdr_version), ntohl(header.hdr_entries));
513
- if (ntohl(header.hdr_entries) < keep_auto)
513
+ if (ntohl(header.hdr_entries) < unpack_limit)
514
do_keep = 0;
515
else
516
do_keep = 1;
@@ -523,7 +523,7 @@ static int get_pack(int xd[2])
523
*av++ = "-v";
524
if (use_thin_pack)
525
*av++ = "--fix-thin";
526
- if (keep_pack > 1 || keep_auto) {
526
+ if (keep_pack > 1 || unpack_limit) {
527
int s = sprintf(keep_arg,
528
"--keep=fetch-pack %d on ", getpid());
529
if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
@@ -642,6 +642,16 @@ static int remove_duplicates(int nr_heads, char **heads)
642
return dst;
643
}
644
645
+static int fetch_pack_config(const char *var, const char *value)
646
+{
647
+ if (strcmp(var, "fetch.unpacklimit") == 0) {
648
+ unpack_limit = git_config_int(var, value);
649
+ return 0;
650
+ }
651
+
652
+ return git_default_config(var, value);
653
+}
654
+
655
static struct lock_file lock;
656
657
int main(int argc, char **argv)
@@ -653,6 +663,8 @@ int main(int argc, char **argv)
663
struct stat st;
664
665
setup_git_directory();
666
+ setup_ident();
667
+ git_config(fetch_pack_config);
668
669
nr_heads = 0;
670
heads = NULL;
@@ -674,16 +686,7 @@ int main(int argc, char **argv)
686
}
687
if (!strcmp("--keep", arg) || !strcmp("-k", arg)) {
688
keep_pack++;
677
- continue;
678
- }
679
- if (!strcmp("--keep-auto", arg)) {
680
- keep_auto = 100;
681
- continue;
682
- }
683
- if (!strncmp("--keep-auto=", arg, 12)) {
684
- keep_auto = strtoul(arg + 12, NULL, 0);
685
- if (keep_auto < 20)
686
- keep_auto = 20;
689
+ unpack_limit = 0;
690
continue;
691
}
692
if (!strcmp("--thin", arg)) {
t/t5500-fetch-pack.sh
+2
-1
@@ -97,7 +97,8 @@ pull_to_client () {
97
(
98
mkdir client &&
99
cd client &&
100
- git-init 2>> log2.txt
100
+ git-init 2>> log2.txt &&
101
+ git repo-config fetch.unpacklimit 0
102
)
103
104
add A1