Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 8815d8a

Browse files
committed
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
2 parents 7b6bc4d + 8640d49 commit 8815d8a

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

Documentation/config.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,11 @@ filter.<driver>.smudge::
11561156
object to a worktree file upon checkout. See
11571157
linkgit:gitattributes[5] for details.
11581158

1159+
gc.aggressiveDepth::
1160+
The depth parameter used in the delta compression
1161+
algorithm used by 'git gc --aggressive'. This defaults
1162+
to 250.
1163+
11591164
gc.aggressiveWindow::
11601165
The window size parameter used in the delta compression
11611166
algorithm used by 'git gc --aggressive'. This defaults

Documentation/git-gc.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ the value, the more time is spent optimizing the delta compression. See
124124
the documentation for the --window' option in linkgit:git-repack[1] for
125125
more details. This defaults to 250.
126126

127+
Similarly, the optional configuration variable 'gc.aggressiveDepth'
128+
controls --depth option in linkgit:git-repack[1]. This defaults to 250.
129+
127130
The optional configuration variable 'gc.pruneExpire' controls how old
128131
the unreferenced loose objects have to be before they are pruned. The
129132
default is "2 weeks ago".

builtin/gc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static const char * const builtin_gc_usage[] = {
2626
};
2727

2828
static int pack_refs = 1;
29+
static int aggressive_depth = 250;
2930
static int aggressive_window = 250;
3031
static int gc_auto_threshold = 6700;
3132
static int gc_auto_pack_limit = 50;
@@ -66,6 +67,10 @@ static int gc_config(const char *var, const char *value, void *cb)
6667
aggressive_window = git_config_int(var, value);
6768
return 0;
6869
}
70+
if (!strcmp(var, "gc.aggressivedepth")) {
71+
aggressive_depth = git_config_int(var, value);
72+
return 0;
73+
}
6974
if (!strcmp(var, "gc.auto")) {
7075
gc_auto_threshold = git_config_int(var, value);
7176
return 0;
@@ -294,7 +299,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
294299

295300
if (aggressive) {
296301
argv_array_push(&repack, "-f");
297-
argv_array_push(&repack, "--depth=250");
302+
if (aggressive_depth > 0)
303+
argv_array_pushf(&repack, "--depth=%d", aggressive_depth);
298304
if (aggressive_window > 0)
299305
argv_array_pushf(&repack, "--window=%d", aggressive_window);
300306
}

environment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ int odb_mkstemp(char *template, size_t limit, const char *pattern)
237237
return xmkstemp_mode(template, mode);
238238
}
239239

240-
int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1)
240+
int odb_pack_keep(char *name, size_t namesz, const unsigned char *sha1)
241241
{
242242
int fd;
243243

git-compat-util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ extern FILE *xfdopen(int fd, const char *mode);
536536
extern int xmkstemp(char *template);
537537
extern int xmkstemp_mode(char *template, int mode);
538538
extern int odb_mkstemp(char *template, size_t limit, const char *pattern);
539-
extern int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1);
539+
extern int odb_pack_keep(char *name, size_t namesz, const unsigned char *sha1);
540540

541541
static inline size_t xsize_t(off_t len)
542542
{

0 commit comments

Comments
 (0)