Re: [PATCH] Add --aggressive option to 'git gc'
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:09
Theodore Tso [off-list ref] writes:
Junio, would you be willing to apply this?
Yes, but ;-).
quoted hunk
static int pack_refs = -1; +static int aggressive_window = -1; +#define MAX_ADD 10 static const char *argv_pack_refs[] = {"pack-refs", "--prune", NULL}; static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL}; -static const char *argv_repack[] = {"repack", "-a", "-d", "-l", NULL}; +static const char *argv_repack[MAX_ADD] = {"repack", "-a", "-d", "-l", NULL}; static const char *argv_prune[] = {"prune", NULL}; static const char *argv_rerere[] = {"rerere", "gc", NULL};@@ -34,13 +36,34 @@ static int gc_config(const char *var, const char *value) pack_refs = git_config_bool(var, value); return 0; } + if (!strcmp(var, "gc.aggressiveWindow")) {
Callbacks to git_config() are called with variable names downcased (except for the 2nd level for 3-level variables. E.g. [REMOTE "Foo"] URL = ...; becomes var = "remote.Foo.url", val = ...).
+ aggressive_window = git_config_int(var, value);
+ printf("aggressive_window = %d\n", aggressive_window);Did you mean to leave this in? Looks like a debug remnant...
+ return 0; + } return git_default_config(var, value); } +static append_option(const char **cmd, const char *opt, int max_length)
Type is "static void" I presume.
+{
+ int i;Funny tab here.
+ + for (i=0; cmd[i]; i++) + ;
SP around operator '='.
+
+ if (i+2 >= max_length) {Same for '+'
+ fprintf(stderr, "Too many options specified\n"); + exit(1);
die("Too many...specified"); /* note the lack of \n at the end */
+ } + cmd[i++] = opt; + cmd[i] = 0;
We tend to spell out NULL, although we all are aware that C says literal '0' is the null pointer. All fixups are trivial so I'd take the patch and amend locally.