Subject: Re: [PATCH] gc: support temporarily preserving garbage

From: Junio C Hamano <[email-masked]>
Date: Fri, 14 Nov 2014 15:01:05 -0800

Brodie Rao <[email-masked]> writes:

> This patch adds a gc.garbageexpire setting that, when not set to "now",
> makes gc (and prune, prune-packed, and repack) move garbage into a
> temporary garbage directory instead of deleting it immediately. The
> garbage directory is then cleared out based on gc.garbageexpire.
>
> The motivation for this setting is to work around various NFS servers
> not supporting delete-on-last-close semantics between NFS clients.
> Without proper support for that, gc could potentially delete objects
> and packs that are in use by git processes on other NFS clients. If
> another git process has a deleted pack file mmap()ed, it could crash
> with a SIGBUS error on Linux.
>
> Signed-off-by: Brodie Rao <[email-masked]>
> ---
>  .gitignore                             |  1 +
>  Documentation/config.txt               | 20 +++++++++
>  Documentation/git-gc.txt               |  7 ++++
>  Documentation/git-prune-garbage.txt    | 55 ++++++++++++++++++++++++
>  Documentation/git-prune-packed.txt     |  9 ++++
>  Documentation/git-prune.txt            |  9 ++++
>  Documentation/git-repack.txt           |  6 +++
>  Documentation/git.txt                  |  6 +++
>  Makefile                               |  2 +
>  builtin.h                              |  1 +
>  builtin/gc.c                           | 20 +++++++++
>  builtin/prune-garbage.c                | 77 ++++++++++++++++++++++++++++++++++
>  builtin/prune-packed.c                 |  3 +-
>  builtin/prune.c                        |  5 ++-
>  builtin/repack.c                       |  7 ++--
>  cache.h                                |  2 +
>  command-list.txt                       |  1 +
>  contrib/completion/git-completion.bash |  2 +
>  environment.c                          | 12 +++++-
>  gc.c                                   | 60 ++++++++++++++++++++++++++
>  gc.h                                   | 16 +++++++
>  git.c                                  |  1 +
>  t/t6502-gc-garbage-expire.sh           | 60 ++++++++++++++++++++++++++
>  23 files changed, 375 insertions(+), 7 deletions(-)
>  create mode 100644 Documentation/git-prune-garbage.txt
>  create mode 100644 builtin/prune-garbage.c
>  create mode 100644 gc.c
>  create mode 100644 gc.h
>  create mode 100755 t/t6502-gc-garbage-expire.sh

I am not sure if this much of code churn is warranted to work around
issues that only happen on repositories on NFS servers that do not
keep open-but-deleted files available.  Is it an option to instead
have a copy of repository locally off NFS?