Miklos Vajna <vmiklos@frugalware.org> writes:
Show 23 quoted lines
> If such a hook is available and exits with a non-zero status, then
> git-gc --auto won't run.
>
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> ---
> builtin-gc.c | 22 ++++++++++++++++++++++
> 1 files changed, 22 insertions(+), 0 deletions(-)
>
> diff --git a/builtin-gc.c b/builtin-gc.c
> index 8cef36f..acd63be 100644
> --- a/builtin-gc.c
> +++ b/builtin-gc.c
> @@ -157,6 +157,25 @@ static int too_many_packs(void)
> return gc_auto_pack_limit <= cnt;
> }
>
> +static int run_hook()
> +{
> + const char *argv[2];
> + struct child_process hook;
> +
> + argv[0] = git_path("hooks/pre-auto-gc");
> + argv[1] = NULL;Hmm. I wonder if the hook wants any parameters, even though I do not think of any offhand.
Show 7 quoted lines
> + if (access(argv[0], X_OK) < 0) > + return 0; > + > + memset(&hook, 0, sizeof(hook)); > + hook.argv = argv; > + hook.no_stdin = 1; > + hook.stdout_to_stderr = 1;
I understand no_stdin, but is there a reason to do stdout_to_stderr?
> + return run_command(&hook); > +}
Don't we want to distinguish between the case where start_command() failed, wait_or_whine() failed on waitpid(), the command was killed with signal, or the command actually ran correctly and decided that you should not run "git gc --auto" by exiting non-zero?
I think it is prudent to refrain from running "git gc --auto" in any of the failure cases I listed above, but shouldn't the cases other than the last one at least issue a warning?