Skip to content

Commit d3154b4

Browse files
dbrysonspearce
authored andcommitted
Use "git_config_string" to simplify "builtin-gc.c" code where "prune_expire" is set
Signed-off-by: David Bryson <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 8753941 commit d3154b4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

builtin-gc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int pack_refs = 1;
2626
static int aggressive_window = -1;
2727
static int gc_auto_threshold = 6700;
2828
static int gc_auto_pack_limit = 50;
29-
static char *prune_expire = "2.weeks.ago";
29+
static const char *prune_expire = "2.weeks.ago";
3030

3131
#define MAX_ADD 10
3232
static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
@@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)
5757
return 0;
5858
}
5959
if (!strcmp(var, "gc.pruneexpire")) {
60-
if (!value)
61-
return config_error_nonbool(var);
62-
if (strcmp(value, "now")) {
60+
if (value && strcmp(value, "now")) {
6361
unsigned long now = approxidate("now");
6462
if (approxidate(value) >= now)
6563
return error("Invalid %s: '%s'", var, value);
6664
}
67-
prune_expire = xstrdup(value);
68-
return 0;
65+
return git_config_string(&prune_expire, var, value);
6966
}
7067
return git_default_config(var, value, cb);
7168
}

0 commit comments

Comments
 (0)