X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-gc.c;h=781df601c5f95e874297e0e8bec3fddeb929cc2d;hb=8561b522d756861a41c0c54dfa2f609c7063887a;hp=f5625bb9fb090f5af4dfb782dc04005a4149a5c8;hpb=438d2991eaa17549df67929cd4558d65840c37d7;p=git.git diff --git a/builtin-gc.c b/builtin-gc.c index f5625bb9f..781df601c 100644 --- a/builtin-gc.c +++ b/builtin-gc.c @@ -18,7 +18,7 @@ #define FAILED_RUN "failed to run %s" static const char * const builtin_gc_usage[] = { - "git-gc [options]", + "git gc [options]", NULL }; @@ -26,7 +26,7 @@ static int pack_refs = 1; static int aggressive_window = -1; static int gc_auto_threshold = 6700; static int gc_auto_pack_limit = 50; -static char *prune_expire = "2.weeks.ago"; +static const char *prune_expire = "2.weeks.ago"; #define MAX_ADD 10 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) return 0; } if (!strcmp(var, "gc.pruneexpire")) { - if (!value) - return config_error_nonbool(var); - if (strcmp(value, "now")) { + if (value && strcmp(value, "now")) { unsigned long now = approxidate("now"); if (approxidate(value) >= now) return error("Invalid %s: '%s'", var, value); } - prune_expire = xstrdup(value); - return 0; + return git_config_string(&prune_expire, var, value); } return git_default_config(var, value, cb); } @@ -134,19 +131,9 @@ static int too_many_packs(void) prepare_packed_git(); for (cnt = 0, p = packed_git; p; p = p->next) { - char path[PATH_MAX]; - size_t len; - int keep; - if (!p->pack_local) continue; - len = strlen(p->pack_name); - if (PATH_MAX <= len + 1) - continue; /* oops, give up */ - memcpy(path, p->pack_name, len-5); - memcpy(path + len - 5, ".keep", 6); - keep = access(p->pack_name, F_OK) && (errno == ENOENT); - if (keep) + if (p->pack_keep) continue; /* * Perhaps check the size of the pack and count only