path: root/builtin/gc.c
diff options
authorJunio C Hamano <>2018-05-08 06:59:33 (GMT)
committerJunio C Hamano <>2018-05-08 06:59:33 (GMT)
commit3915f9a4fa2ae48b282a71f72113ca8629b27618 (patch)
treec273799cdec3a91d09c93db595311b9ca1975ea3 /builtin/gc.c
parentad3207e6ff019060e4f634a5455aa0ae248e3a7a (diff)
parent8ab5aa4bd8e218b9658dbdd7f5bfcaa512f607dc (diff)
Merge branch 'jc/parseopt-expiry-errors'
"git gc --prune=nonsense" spent long time repacking and then silently failed when underlying "git prune --expire=nonsense" failed to parse its command line. This has been corrected. * jc/parseopt-expiry-errors: parseopt: handle malformed --expire arguments more nicely gc: do not upcase error message shown with die()
Diffstat (limited to 'builtin/gc.c')
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index 3e67124..d604940 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -354,6 +354,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
const char *name;
pid_t pid;
int daemonized = 0;
+ timestamp_t dummy;
struct option builtin_gc_options[] = {
OPT__QUIET(&quiet, N_("suppress progress reporting")),
@@ -382,7 +383,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
/* default expiry time, overwritten in gc_config */
if (parse_expiry_date(gc_log_expire, &gc_log_expire_time))
- die(_("Failed to parse gc.logexpiry value %s"), gc_log_expire);
+ die(_("failed to parse gc.logexpiry value %s"), gc_log_expire);
if (pack_refs < 0)
pack_refs = !is_bare_repository();
@@ -392,6 +393,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
if (argc > 0)
usage_with_options(builtin_gc_usage, builtin_gc_options);
+ if (prune_expire && parse_expiry_date(prune_expire, &dummy))
+ die(_("failed to parse prune expiry value %s"), prune_expire);
if (aggressive) {
argv_array_push(&repack, "-f");
if (aggressive_depth > 0)