From: Junio C Hamano Date: Thu, 3 Apr 2014 19:38:46 +0000 (-0700) Subject: Merge branch 'nd/gc-aggressive' X-Git-Tag: v2.0.0-rc0~25 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/8815d8aa7ccab3798fa5513821ab110c209b0ae7?ds=inline;hp=-c Merge branch 'nd/gc-aggressive' Allow tweaking the maximum length of the delta-chain produced by "gc --aggressive". * nd/gc-aggressive: environment.c: fix constness for odb_pack_keep() gc --aggressive: make --depth configurable --- 8815d8aa7ccab3798fa5513821ab110c209b0ae7 diff --combined Documentation/config.txt index c415aadbbc,5ce7f9a68b..84c7e3f11a --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -131,13 -131,8 +131,13 @@@ Variable Note that this list is non-comprehensive and not necessarily complete. For command-specific variables, you will find a more detailed description -in the appropriate manual page. You will find a description of non-core -porcelain configuration variables in the respective porcelain documentation. +in the appropriate manual page. + +Other git-related tools may and do use their own variables. When +inventing new variables for use in your own tool, make sure their +names do not conflict with those that are used by Git itself and +other popular tools, and describe them in your documentation. + advice.*:: These variables control various optional help messages designed to @@@ -1156,6 -1151,11 +1156,11 @@@ filter..smudge: object to a worktree file upon checkout. See linkgit:gitattributes[5] for details. + gc.aggressiveDepth:: + The depth parameter used in the delta compression + algorithm used by 'git gc --aggressive'. This defaults + to 250. + gc.aggressiveWindow:: The window size parameter used in the delta compression algorithm used by 'git gc --aggressive'. This defaults @@@ -2161,13 -2161,6 +2166,13 @@@ repack.usedeltabaseoffset: "false" and repack. Access from old Git versions over the native protocol are unaffected by this option. +repack.packKeptObjects:: + If set to true, makes `git repack` act as if + `--pack-kept-objects` was passed. See linkgit:git-repack[1] for + details. Defaults to `false` normally, but `true` if a bitmap + index is being written (either via `--write-bitmap-index` or + `pack.writeBitmaps`). + rerere.autoupdate:: When set to true, `git-rerere` updates the index with the resulting contents after it cleanly resolves conflicts using diff --combined builtin/gc.c index 11cf295515,72aa91206d..85f5c2bc62 --- a/builtin/gc.c +++ b/builtin/gc.c @@@ -26,6 -26,7 +26,7 @@@ static const char * const builtin_gc_us }; static int pack_refs = 1; + static int aggressive_depth = 250; static int aggressive_window = 250; static int gc_auto_threshold = 6700; static int gc_auto_pack_limit = 50; @@@ -66,6 -67,10 +67,10 @@@ static int gc_config(const char *var, c aggressive_window = git_config_int(var, value); return 0; } + if (!strcmp(var, "gc.aggressivedepth")) { + aggressive_depth = git_config_int(var, value); + return 0; + } if (!strcmp(var, "gc.auto")) { gc_auto_threshold = git_config_int(var, value); return 0; @@@ -184,7 -189,7 +189,7 @@@ static int need_to_gc(void else if (!too_many_loose_objects()) return 0; - if (run_hook(NULL, "pre-auto-gc", NULL)) + if (run_hook_le(NULL, "pre-auto-gc", NULL)) return 0; return 1; } @@@ -294,7 -299,8 +299,8 @@@ int cmd_gc(int argc, const char **argv if (aggressive) { argv_array_push(&repack, "-f"); - argv_array_push(&repack, "--depth=250"); + if (aggressive_depth > 0) + argv_array_pushf(&repack, "--depth=%d", aggressive_depth); if (aggressive_window > 0) argv_array_pushf(&repack, "--window=%d", aggressive_window); } diff --combined git-compat-util.h index 892032bc79,adbfb5e42f..9158ed634a --- a/git-compat-util.h +++ b/git-compat-util.h @@@ -343,11 -343,8 +343,11 @@@ extern int ends_with(const char *str, c static inline const char *skip_prefix(const char *str, const char *prefix) { - size_t len = strlen(prefix); - return strncmp(str, prefix, len) ? NULL : str + len; + do { + if (!*prefix) + return str; + } while (*str++ == *prefix++); + return NULL; } #if defined(NO_MMAP) || defined(USE_WIN32_MMAP) @@@ -536,7 -533,7 +536,7 @@@ extern FILE *xfdopen(int fd, const cha extern int xmkstemp(char *template); extern int xmkstemp_mode(char *template, int mode); extern int odb_mkstemp(char *template, size_t limit, const char *pattern); - extern int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1); + extern int odb_pack_keep(char *name, size_t namesz, const unsigned char *sha1); static inline size_t xsize_t(off_t len) {