summaryrefslogtreecommitdiff
path: root/builtin-gc.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-02-15 00:05:11 -0800
committerJunio C Hamano <gitster@pobox.com>2009-02-15 00:05:11 -0800
commit43e35f6bc14c6e00148a01700e3df191aa99c9f7 (patch)
treed1f5a26891a6f990833bc096f04dc1157aabde48 /builtin-gc.c
parentb43174ebf12299ba3da3007c1e759613af153f6c (diff)
parent58e9d9d472ff4dbc6cfbf7459878778c739395eb (diff)
downloadgit-43e35f6bc14c6e00148a01700e3df191aa99c9f7.tar.gz
Merge branch 'js/gc-prune'
* js/gc-prune: gc: make --prune useful again by accepting an optional parameter
Diffstat (limited to 'builtin-gc.c')
-rw-r--r--builtin-gc.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/builtin-gc.c b/builtin-gc.c
index a2014388da..8d990ed493 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -161,7 +161,8 @@ static int need_to_gc(void)
*/
if (too_many_packs())
append_option(argv_repack,
- !strcmp(prune_expire, "now") ? "-a" : "-A",
+ prune_expire && !strcmp(prune_expire, "now") ?
+ "-a" : "-A",
MAX_ADD);
else if (!too_many_loose_objects())
return 0;
@@ -173,14 +174,15 @@ static int need_to_gc(void)
int cmd_gc(int argc, const char **argv, const char *prefix)
{
- int prune = 0;
int aggressive = 0;
int auto_gc = 0;
int quiet = 0;
char buf[80];
struct option builtin_gc_options[] = {
- OPT_BOOLEAN(0, "prune", &prune, "prune unreferenced objects (deprecated)"),
+ { OPTION_STRING, 0, "prune", &prune_expire, "date",
+ "prune unreferenced objects",
+ PARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },
OPT_BOOLEAN(0, "aggressive", &aggressive, "be more thorough (increased runtime)"),
OPT_BOOLEAN(0, "auto", &auto_gc, "enable auto-gc mode"),
OPT_BOOLEAN('q', "quiet", &quiet, "suppress progress reports"),
@@ -218,7 +220,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
"\"git help gc\" for more information.\n");
} else
append_option(argv_repack,
- !strcmp(prune_expire, "now") ? "-a" : "-A",
+ prune_expire && !strcmp(prune_expire, "now")
+ ? "-a" : "-A",
MAX_ADD);
if (pack_refs && run_command_v_opt(argv_pack_refs, RUN_GIT_CMD))
@@ -230,9 +233,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
if (run_command_v_opt(argv_repack, RUN_GIT_CMD))
return error(FAILED_RUN, argv_repack[0]);
- argv_prune[2] = prune_expire;
- if (run_command_v_opt(argv_prune, RUN_GIT_CMD))
- return error(FAILED_RUN, argv_prune[0]);
+ if (prune_expire) {
+ argv_prune[2] = prune_expire;
+ if (run_command_v_opt(argv_prune, RUN_GIT_CMD))
+ return error(FAILED_RUN, argv_prune[0]);
+ }
if (run_command_v_opt(argv_rerere, RUN_GIT_CMD))
return error(FAILED_RUN, argv_rerere[0]);