Merge branch 'nd/gc-aggressive'
authorJunio C Hamano <gitster@pobox.com>
Thu, 3 Apr 2014 19:38:46 +0000 (12:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Apr 2014 19:38:47 +0000 (12:38 -0700)
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

1  2 
Documentation/config.txt
builtin/gc.c
git-compat-util.h
diff --combined Documentation/config.txt
index c415aadbbcd8b6b99f21687e1038867a0d2bf0cf,5ce7f9a68b48645841a81b142995228e07292575..84c7e3f11ae9b8b13815abc3b30db0489f493c30
@@@ -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.<driver>.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 11cf295515a25b1df19af7a14c2cd03911d957b5,72aa91206d7e9b0c857597b5438b6ada9c7868bc..85f5c2bc62ec1ead593f5aa2e3d7077e65f2f061
@@@ -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 892032bc79b88c9180f9f4c8ba171407d7c784ed,adbfb5e42fe68b0bdd72774f416791933cbdb372..9158ed634a8f62fd6c248fbfbc0978fae608b108
@@@ -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)
  {