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

Re: [PATCH 1/6] templates: Use heredoc in pre-commit hook

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 14, 2013, 18:09 UTC
Message-ID
<20130714180916.GB1267@google.com>
In-Reply-To
<1373818879-1698-2-git-send-email-richih.mailinglist@gmail.com>
Hi,
Richard Hartmann wrote:
> Spawning a new subprocess for every line printed is inefficient.
> Use heredoc, instead.

I think this makes sense as a code clarity, simplicity, and internationalizability improvement, but don't like the precedent of eliminating 'echo' for the sake of fork removal (unless we have measurements showing it's worthwhile, which would be included here).

Maybe a simpler commit message could sidestep the issue?
	Use a heredoc instead of an "echo" for each line.
> Based on 98770971aef8d1cbc78876d9023d10aa25df0526 in original patch
> series from 2013-06-10.

Please don't include this. The audience for the commit message doesn't have that commit to compare to.

If you want to preserve the original date, the way to do that is a "Date:" field at the top of the message body.

	Date: Fri, 28 Jun 2013 21:16:19 +0530
	Spawning a new subprocess for ...
[...]
Show 19 quoted lines
> --- a/templates/hooks--pre-commit.sample
> +++ b/templates/hooks--pre-commit.sample
> @@ -31,18 +31,19 @@ if [ "$allownonascii" != "true" ] &&
>  	test $(git diff --cached --name-only --diff-filter=A -z $against |
>  	  LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
>  then
> -	echo "Error: Attempt to add a non-ascii file name."
> -	echo
> -	echo "This can cause problems if you want to work"
> -	echo "with people on other platforms."
> -	echo
> -	echo
> -	echo "If you know what you are doing you can disable this"
> -	echo "check using:"
> -	echo
> -	echo "  git config hooks.allownonascii true"
> -	echo
> +	cat <<-EOF
> +Error: Attempt to add a non-ascii file name.
Using
	cat <<\EOF

would make reading easier since the reader then doesn't have to worry about whether the text being cat'ed is indented or uses variable substitutions.

> -	echo "To be portable it is advisable to rename the file ..."
> +To be portable it is advisable to rename the file.
Yes, nice.

With the above nits addressed, this change looks to be going in the right direction. Thanks.

Hope that helps, Jonathan

Previous: Richard HartmannNext: Junio C Hamano
Message 20 of 35 in “Janitorial work on hook templates”
  1. 0/4 Janitorial work on hook templatesRichard Hartmann, Jun 10, 2013
  2. 1/6 templates: Fewer subprocesses in pre-commit hookRichard Hartmann, Jun 10, 2013
  3. Junio C HamanoJun 10, 2013
  4. Richard HartmannJun 10, 2013
  5. Jeff KingJun 10, 2013
  6. 2/6 templates: Reformat pre-commit hook's messageRichard Hartmann, Jun 10, 2013
  7. Junio C HamanoJun 10, 2013
  8. 3/6 templates: Fix spelling in pre-commit hookRichard Hartmann, Jun 10, 2013
  9. 4/6 Documentation: Update manpage for pre-commit hookRichard Hartmann, Jun 10, 2013
  10. 5/6 templates: Fix ASCII art in pre-rebase hookRichard Hartmann, Jun 10, 2013
  11. Junio C HamanoJun 10, 2013
  12. Jeff KingJun 10, 2013
  13. 6/6 template: Fix comment indentation in pre-rebase hookRichard Hartmann, Jun 10, 2013
  14. Junio C HamanoJun 10, 2013
  15. Richard HartmannJun 10, 2013
  16. Junio C HamanoJun 10, 2013
  17. Richard HartmannJun 10, 2013
  18. 0/6 Update to janitorial work on hook templatesRichard Hartmann, Jul 14, 2013
  19. 1/6 templates: Use heredoc in pre-commit hookRichard Hartmann, Jul 14, 2013
  20. Jonathan NiederJul 14, 2013
  21. Junio C HamanoJul 15, 2013
  22. Junio C HamanoJul 14, 2013
  23. Richard HartmannJul 14, 2013
  24. Jonathan NiederJul 14, 2013
  25. Junio C HamanoJul 15, 2013
  26. 2/6 templates: Reformat pre-commit hook's messageRichard Hartmann, Jul 14, 2013
  27. Jonathan NiederJul 14, 2013
  28. 3/6 templates: Fix spelling in pre-commit hookRichard Hartmann, Jul 14, 2013
  29. 4/6 Documentation: Update manpage for pre-commit hookRichard Hartmann, Jul 14, 2013
  30. Jonathan NiederJul 14, 2013
  31. Junio C HamanoJul 15, 2013
  32. 5/6 templates: Fix ASCII art in pre-rebase hookRichard Hartmann, Jul 14, 2013
  33. Jonathan NiederJul 14, 2013
  34. 6/6 template: Fix comment indentation in pre-rebase hookRichard Hartmann, Jul 14, 2013
  35. Jonathan NiederJul 14, 2013

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.