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

Re: [PATCH v2] hooks: Add ability to specify where the hook directory is

From
Johannes Sixt <j6t@kdbg.org>
Date
Apr 25, 2016, 19:11 UTC
Message-ID
<571E6BCF.5020606@kdbg.org>
In-Reply-To
<1461532702-4045-1-git-send-email-avarab@gmail.com>
Am 24.04.2016 um 23:18 schrieb Ævar Arnfjörð Bjarmason:
Show 10 quoted lines
> +test_expect_success 'set up a pre-commit hook in core.hooksPath' '
> +	mkdir -p .git/custom-hooks .git/hooks &&
> +	write_script .git/custom-hooks/pre-commit <<EOF &&
> +printf "%s" "." >>.git/PRE-COMMIT-HOOK-WAS-CALLED
> +EOF
> +	cat >.git/hooks/pre-commit <<EOF &&
> +	write_script .git/hooks/pre-commit &&
> +printf "%s" "SHOULD NOT BE CALLED" >>.git/PRE-COMMIT-HOOK-WAS-CALLED
> +EOF
> +	chmod +x .git/custom-hooks/pre-commit

Here I see a half-baked attempt to use write_script. Once you've fixed that, we have a pre-commit hook in the regular hook directory. Obviously, the hook is expected not to be called...

> +'
> +
> +test_expect_success 'Check that various forms of specifying core.hooksPath work' '
> +	test_commit no_custom_hook &&
... but at this point, it *will* be called...
Show 9 quoted lines
> +	git config core.hooksPath .git/custom-hooks &&
> +	test_commit have_custom_hook &&
> +	git config core.hooksPath .git/custom-hooks/ &&
> +	test_commit have_custom_hook_trailing_slash &&
> +	git config core.hooksPath "$PWD/.git/custom-hooks" &&
> +	test_commit have_custom_hook_abs_path &&
> +	git config core.hooksPath "$PWD/.git/custom-hooks/" &&
> +	test_commit have_custom_hook_abs_path_trailing_slash &&
> +	printf "%s" "...." >.git/PRE-COMMIT-HOOK-WAS-CALLED.expect &&
... and this expectation is wrong.
Show 5 quoted lines
> +	test_cmp .git/PRE-COMMIT-HOOK-WAS-CALLED.expect .git/PRE-COMMIT-HOOK-WAS-CALLED
> +'
> +
> +test_done
>

I feel a bit uneasy that expected and actual files are not POSIXly correct text files, i.e., the LF at the end is missing...

-- Hannes
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 6 of 10 in “hooks: Add ability to specify where the hook directory is”
  1. hooks: Add ability to specify where the hook directory isÆvar Arnfjörð Bjarmason, Apr 22, 2016
  2. SZEDER GáborApr 23, 2016
  3. Ævar Arnfjörð BjarmasonApr 23, 2016
  4. hooks: Add ability to specify where the hook directory isÆvar Arnfjörð Bjarmason, Apr 24, 2016
  5. Ævar Arnfjörð BjarmasonApr 25, 2016
  6. Johannes SixtApr 25, 2016
  7. Junio C HamanoApr 25, 2016
  8. Ævar Arnfjörð BjarmasonApr 26, 2016
  9. Junio C HamanoApr 26, 2016
  10. Ævar Arnfjörð BjarmasonApr 26, 2016

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.