git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/4] git-gc --auto: add pre-auto-gc hook

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 1, 2008, 04:51 UTC
Message-ID
<7vsky6jhz3.fsf@gitster.siamese.dyndns.org>
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?

Next: Miklos Vajna
Message 1 of 21 in “Re: [PATCH 1/4] git-gc --auto: add pre-auto-gc hook”
  1. Junio C HamanoApr 1, 2008
  2. 0/4 add pre-auto-gc hook for git-gc --auto (try2)Miklos Vajna, Apr 1, 2008
  3. Junio C HamanoApr 1, 2008
  4. Miklos VajnaApr 2, 2008
  5. Junio C HamanoApr 2, 2008
  6. Miklos VajnaApr 2, 2008
  7. Junio C HamanoApr 2, 2008
  8. 0/3 add pre-auto-gc hook for git-gc --auto (try3)Miklos Vajna, Apr 2, 2008
  9. 1/3 git-gc --auto: add pre-auto-gc hookMiklos Vajna, Apr 2, 2008
  10. 2/3 Documentation/hooks: add pre-auto-gc hookMiklos Vajna, Apr 2, 2008
  11. 3/3 contrib/hooks: add an example pre-auto-gc hookMiklos Vajna, Apr 2, 2008
  12. Junio C HamanoApr 2, 2008
  13. 3/3 contrib/hooks: add an example pre-auto-gc hookMiklos Vajna, Apr 2, 2008
  14. Junio C HamanoApr 2, 2008
  15. Miklos VajnaApr 2, 2008
  16. tests for pre-auto-gc hook (WAS: Re: [PATCH 3/3] contrib/hooks: add an example pre-auto-gc hook)Miklos Vajna, Apr 3, 2008
  17. Johannes SixtApr 4, 2008
  18. 1/4 git-gc --auto: add pre-auto-gc hookMiklos Vajna, Apr 1, 2008
  19. 2/4 Documentation/hooks: add pre-auto-gc hookMiklos Vajna, Apr 1, 2008
  20. 3/4 templates: add an example pre-auto-gc hookMiklos Vajna, Apr 1, 2008
  21. 4/4 contrib/hooks: add an example pre-auto-gc hookMiklos Vajna, Apr 1, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.