git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Richard Hartmann <richih.mailinglist@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/6] templates: Use heredoc in pre-commit hook
Date: Sun, 14 Jul 2013 12:20:56 -0700	[thread overview]
Message-ID: <7v1u71gd7r.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1373818879-1698-2-git-send-email-richih.mailinglist@gmail.com> (Richard Hartmann's message of "Sun, 14 Jul 2013 18:21:14 +0200")

Richard Hartmann <richih.mailinglist@gmail.com> writes:

> Spawning a new subprocess for every line printed is inefficient.

This is not a valid justification at all, is it?  

Shells on modern distros and platforms have "echo" built-in, so this
patch replaces series of writes internal to the shell with a fork to
cat with heredoc (which often is implemented with a temporary file).




> Use heredoc, instead.
>
> Based on 98770971aef8d1cbc78876d9023d10aa25df0526 in original patch
> series from 2013-06-10.
>
> Signed-off-by: Richard Hartmann <richih.mailinglist@gmail.com>
> ---
>  templates/hooks--pre-commit.sample |   25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample
> index 18c4829..889967c 100755
> --- 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 "To be portable it is advisable to rename the file ..."
> -	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.
> +
> +This can cause problems if you want to work
> +with people on other platforms.
> +
> +To be portable it is advisable to rename the file.
> +
> +If you know what you are doing you can disable this
> +check using:
> +
> +  git config hooks.allownonascii true
> +EOF
>  	exit 1
>  fi

  parent reply	other threads:[~2013-07-14 19:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-10 18:35 [PATCH 0/4] Janitorial work on hook templates Richard Hartmann
2013-06-10 18:36 ` [PATCH 1/6] templates: Fewer subprocesses in pre-commit hook Richard Hartmann
2013-06-10 19:44   ` Junio C Hamano
2013-06-10 20:39     ` Richard Hartmann
2013-06-10 21:25   ` Jeff King
2013-06-10 18:36 ` [PATCH 2/6] templates: Reformat pre-commit hook's message Richard Hartmann
2013-06-10 19:47   ` Junio C Hamano
2013-06-10 18:36 ` [PATCH 3/6] templates: Fix spelling in pre-commit hook Richard Hartmann
2013-06-10 18:36 ` [PATCH 4/6] Documentation: Update manpage for " Richard Hartmann
2013-06-10 18:36 ` [PATCH 5/6] templates: Fix ASCII art in pre-rebase hook Richard Hartmann
2013-06-10 19:51   ` Junio C Hamano
2013-06-10 21:29   ` Jeff King
2013-06-10 18:36 ` [PATCH 6/6] template: Fix comment indentation " Richard Hartmann
2013-06-10 19:52   ` Junio C Hamano
2013-06-10 21:46     ` Richard Hartmann
2013-06-10 22:57       ` Junio C Hamano
2013-06-10 23:03         ` Richard Hartmann
2013-07-14 16:21           ` [PATCH 0/6] Update to janitorial work on hook templates Richard Hartmann
2013-07-14 16:21             ` [PATCH 1/6] templates: Use heredoc in pre-commit hook Richard Hartmann
2013-07-14 18:09               ` Jonathan Nieder
2013-07-15  3:22                 ` Junio C Hamano
2013-07-14 19:20               ` Junio C Hamano [this message]
2013-07-14 20:12                 ` Richard Hartmann
2013-07-14 20:20                   ` Jonathan Nieder
2013-07-15 16:49                   ` Junio C Hamano
2013-07-14 16:21             ` [PATCH 2/6] templates: Reformat pre-commit hook's message Richard Hartmann
2013-07-14 18:42               ` Jonathan Nieder
2013-07-14 16:21             ` [PATCH 3/6] templates: Fix spelling in pre-commit hook Richard Hartmann
2013-07-14 16:21             ` [PATCH 4/6] Documentation: Update manpage for " Richard Hartmann
2013-07-14 18:51               ` Jonathan Nieder
2013-07-15 16:54               ` Junio C Hamano
2013-07-14 16:21             ` [PATCH 5/6] templates: Fix ASCII art in pre-rebase hook Richard Hartmann
2013-07-14 18:52               ` Jonathan Nieder
2013-07-14 16:21             ` [PATCH 6/6] template: Fix comment indentation " Richard Hartmann
2013-07-14 18:53               ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v1u71gd7r.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=richih.mailinglist@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).