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

Re: [PATCH v5 0/4] githooks.txt improvements + core.hooksDirectory

From
Junio C Hamano <gitster@pobox.com>
Date
May 4, 2016, 22:13 UTC
Message-ID
<xmqqa8k5eakb.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1462393128-26762-1-git-send-email-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
> For convenience & ease of review a diff between the bits of v4 and v5
> that I changed follows below.
Thanks.
Show 6 quoted lines
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> ...
> +This configuration variable is useful in cases where you'd like to
> +centrally configure your Git hooks instead of configuring them on a
> +per-repository basis, or as a more flexible and centralized
> +alterantive to having an `init.templateDir` where you've changed
"alternative" (can be locally amended).
Show 7 quoted lines
> diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
> ...
> +Hooks don't need to worry about the user's current working
> +directory. Before Git invokes a hook it changes its working
> +directory. The working directory will be the root of the working tree
> +in a non-bare repository, or in the $GIT_DIR directory in a bare
> +repository.

I suspect that the first sentence does more harm than good. When you say "don't need to worry about", somebody is bound to ask "that is good that I do not need to, but what if I _want_ to know?", and you do not have a good answer to that question.

	Before Git invokes a hook, it changes its working directory
	to either the root of the working tree in a non-bare
	repository, or to the $GIT_DIR in a bare repository.
perhaps?
Show 16 quoted lines
> diff --git a/t/t1350-config-hooks-path.sh b/t/t1350-config-hooks-path.sh
> index f2f0aa9..6e4586a 100755
> --- a/t/t1350-config-hooks-path.sh
> +++ b/t/t1350-config-hooks-path.sh
> @@ -7,10 +7,10 @@ test_description='Test the core.hooksPath configuration variable'
>  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" "CUST" >>.git/PRE-COMMIT-HOOK-WAS-CALLED
> +	echo CUSTOM >>actual
>  EOF
>  	write_script .git/hooks/pre-commit <<-\EOF
> -printf "%s" "NORM" >>.git/PRE-COMMIT-HOOK-WAS-CALLED
> +	echo NORMAL >>actual
>  EOF
>  '

These closing EOF can and should be indented like the body of the here-text, i.e.

	cmd <<-\EOF &&
        ...
        EOF
Show 13 quoted lines
> @@ -24,8 +24,14 @@ test_expect_success 'Check that various forms of specifying core.hooksPath work'
>  	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" "NORMCUSTCUSTCUSTCUST" >.git/PRE-COMMIT-HOOK-WAS-CALLED.expect &&
> -	test_cmp .git/PRE-COMMIT-HOOK-WAS-CALLED.expect .git/PRE-COMMIT-HOOK-WAS-CALLED
> +	cat >expect <<-\EOF &&
> +	NORMAL
> +	CUSTOM
> +	CUSTOM
> +	CUSTOM
> +	CUSTOM
> +EOF
Likewise.
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 14 of 20 in “githooks.txt improvements + core.hooksDirectory”
  1. 0/4 githooks.txt improvements + core.hooksDirectoryÆvar Arnfjörð Bjarmason, Apr 26, 2016
  2. 1/4 githooks.txt: Improve the intro sectionÆvar Arnfjörð Bjarmason, Apr 26, 2016
  3. Junio C HamanoApr 26, 2016
  4. 2/4 githooks.txt: Amend dangerous advice about 'update' hook ACLÆvar Arnfjörð Bjarmason, Apr 26, 2016
  5. Junio C HamanoApr 26, 2016
  6. 3/4 githooks.txt: Minor improvements to the grammar & phrasingÆvar Arnfjörð Bjarmason, Apr 26, 2016
  7. 4/4 hooks: Add ability to specify where the hook directory isÆvar Arnfjörð Bjarmason, Apr 26, 2016
  8. Junio C HamanoApr 26, 2016
  9. 0/4 githooks.txt improvements + core.hooksDirectoryÆvar Arnfjörð Bjarmason, May 4, 2016
  10. 1/4 githooks.txt: Improve the intro sectionÆvar Arnfjörð Bjarmason, May 4, 2016
  11. 2/4 githooks.txt: Amend dangerous advice about 'update' hook ACLÆvar Arnfjörð Bjarmason, May 4, 2016
  12. 3/4 githooks.txt: Minor improvements to the grammar & phrasingÆvar Arnfjörð Bjarmason, May 4, 2016
  13. 4/4 hooks: Add ability to specify where the hook directory isÆvar Arnfjörð Bjarmason, May 4, 2016
  14. Junio C HamanoMay 4, 2016
  15. 0/4 githooks.txt improvements + core.hooksDirectoryÆvar Arnfjörð Bjarmason, May 4, 2016
  16. 1/4 githooks.txt: Improve the intro sectionÆvar Arnfjörð Bjarmason, May 4, 2016
  17. 2/4 githooks.txt: Amend dangerous advice about 'update' hook ACLÆvar Arnfjörð Bjarmason, May 4, 2016
  18. 3/4 githooks.txt: Minor improvements to the grammar & phrasingÆvar Arnfjörð Bjarmason, May 4, 2016
  19. 4/4 hooks: Add ability to specify where the hook directory isÆvar Arnfjörð Bjarmason, May 4, 2016
  20. Junio C HamanoMay 4, 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.