Re: [PATCH] gc --auto: release pack files before auto packing
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jun 30, 2018, 14:58 UTC
- Message-ID
- <20180630145849.GA9416@duynguyen.home>
- In-Reply-To
- <20180630133822.4580-1-kgybels@infogroep.be>
On Sat, Jun 30, 2018 at 03:38:21PM +0200, Kim Gybels wrote:
Show 27 quoted lines
> Teach gc --auto to release pack files before auto packing the repository
> to prevent failures when removing them.
>
> Also teach the test 'fetching with auto-gc does not lock up' to complain
> when it is no longer triggering an auto packing of the repository.
>
> Fixes https://github.com/git-for-windows/git/issues/500
>
> Signed-off-by: Kim Gybels <kgybels@infogroep.be>
> ---
>
> Patch based on master, since problem doesn't reproduce on maint,
> however, the improvement to the test might be valuable on maint.
>
> builtin/gc.c | 1 +
> t/t5510-fetch.sh | 2 ++
> 2 files changed, 3 insertions(+)
>
> diff --git a/builtin/gc.c b/builtin/gc.c
> index ccfb1ceaeb..63b62ab57c 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -612,6 +612,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
> return -1;
>
> if (!repository_format_precious_objects) {
> + close_all_packs(the_repository->objects);We have repo_clear() which does this and potentially closing file descriptors on other things as well. I suggest we use it, and before any external command is run. Something like
diff --git a/builtin/gc.c b/builtin/gc.c index ccfb1ceaeb..a852c71da6 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -473,6 +473,13 @@ static int report_last_gc_error(void) static int gc_before_repack(void) { + /* + * Shut down everything, we should have all the info we need + * at this point. Leaving some file descriptors open may + * prevent them from being removed on Windows. + */ + repo_clear(the_repository); + if (pack_refs && run_command_v_opt(pack_refs_cmd.argv, RUN_GIT_CMD)) return error(FAILED_RUN, pack_refs_cmd.argv[0]); > if (run_command_v_opt(repack.argv, RUN_GIT_CMD)) > return error(FAILED_RUN, repack.argv[0]); > > diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh > index e402aee6a2..b91637e48f 100755 > --- a/t/t5510-fetch.sh > +++ b/t/t5510-fetch.sh > @@ -828,9 +828,11 @@ test_expect_success 'fetching with auto-gc does not lock up' ' > test_commit test2 && > ( > cd auto-gc && > + git config fetch.unpackLimit 1 && > git config gc.autoPackLimit 1 && > git config gc.autoDetach false && > GIT_ASK_YESNO="$D/askyesno" git fetch >fetch.out 2>&1 && > + grep "Auto packing the repository" fetch.out && Not sure if this should be test_i18ngrep > ! grep "Should I try again" fetch.out > ) > ' > -- > 2.18.0.windows.1 >