Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- Documentation/config.txt | 7 +++++++ Documentation/git-checkout.txt | 2 +- builtin/gc.c | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 286e539..a85f684 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1211,6 +1211,13 @@ gc.pruneexpire:: "now" may be used to disable this grace period and always prune unreachable objects immediately. +gc.pruneworktreesexpire:: + When 'git gc' is run, it will call + 'prune --worktrees --expire 3.months.ago'. + Override the grace period with this config variable. The value + "now" may be used to disable the grace period and prune + $GIT_DIR/worktrees immediately. + gc.reflogexpire:: gc.<pattern>.reflogexpire:: 'git reflog expire' removes reflog entries older than diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index a29748e..23f0c80 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -433,7 +433,7 @@ inside $GIT_DIR. Use `git rev-parse --git-path` to get the final path. When you are done, simply deleting the linked working directory would suffice. $GIT_DIR/worktrees can be cleaned up using `git prune ---worktrees`. +--worktrees`, which is part of automated garbage collection. After you move a linked working directory to another file system, or on a file system that does not support hard link, execute any git diff --git a/builtin/gc.c b/builtin/gc.c index e38c902..00239ca 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -33,11 +33,13 @@ static int gc_auto_threshold = 6700; static int gc_auto_pack_limit = 50; static int detach_auto = 1; static const char *prune_expire = "2.weeks.ago"; +static const char *prune_worktrees_expire = "3.months.ago"; static struct argv_array pack_refs_cmd = ARGV_ARRAY_INIT; static struct argv_array reflog = ARGV_ARRAY_INIT; static struct argv_array repack = ARGV_ARRAY_INIT; static struct argv_array prune = ARGV_ARRAY_INIT; +static struct argv_array prune_worktrees = ARGV_ARRAY_INIT; static struct argv_array rerere = ARGV_ARRAY_INIT; static char *pidfile; @@ -97,6 +99,8 @@ static int gc_config(const char *var, const char *value, void *cb) } if (!strcmp(var, "gc.pruneexpire")) return git_config_date_string(&prune_expire, var, value); + if (!strcmp(var, "gc.pruneworktreesexpire")) + return git_config_date_string(&prune_worktrees_expire, var, value); return git_default_config(var, value, cb); } @@ -304,6 +308,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix) argv_array_pushl(&reflog, "reflog", "expire", "--all", NULL); argv_array_pushl(&repack, "repack", "-d", "-l", NULL); argv_array_pushl(&prune, "prune", "--expire", NULL); + argv_array_pushl(&prune_worktrees, "prune", "--worktrees", "--expire", NULL); argv_array_pushl(&rerere, "rerere", "gc", NULL); git_config(gc_config, NULL); @@ -373,6 +378,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix) return error(FAILED_RUN, prune.argv[0]); } + if (prune_worktrees_expire) { + argv_array_push(&prune_worktrees, prune_worktrees_expire); + if (run_command_v_opt(prune_worktrees.argv, RUN_GIT_CMD)) + return error(FAILED_RUN, prune_worktrees.argv[0]); + } + if (run_command_v_opt(rerere.argv, RUN_GIT_CMD)) return error(FAILED_RUN, rerere.argv[0]); -- 2.1.0.rc0.78.gc0d8480 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html