* [PATCH] pre-commit.sample: don't print incidental SHA1
@ 2009-05-16 10:21 Jim Meyering
2009-05-16 19:12 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Jim Meyering @ 2009-05-16 10:21 UTC (permalink / raw)
To: git list
Make the sample pre-commit hook script discard
all git-rev-parse output, not just stderr.
Otherwise, it would print an SHA1.
Signed-off-by: Jim Meyering <meyering@redhat.com>
---
[this patch applies at least to "next"]
I enabled the sample pre-commit hook and was surprised to
see new output with every commit. It was due to that script's
use of git-rev-parse.
Also, I noticed the use of "git-hyphen" git-rev-parse.
Perhaps that hyphen has been left in deliberately,
for portability to very old versions of git?
While the 800+ uses of "git rev-parse" far outnumber uses of the
two-hyphen version, this is far from being the only use in code
(this is on the "next" branch):
$ git grep -l git-rev-parse|grep -vE 'Docu|command-list|\.giti'
contrib/emacs/git.el
contrib/examples/git-revert.sh
git-archimport.perl
git-cvsexportcommit.perl
git-cvsimport.perl
git-submodule.sh
gitweb/gitweb.perl
perl/Git.pm
templates/hooks--pre-commit.sample
templates/hooks--pre-commit.sample | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample
index 0e49279..0ba6207 100755
--- a/templates/hooks--pre-commit.sample
+++ b/templates/hooks--pre-commit.sample
@@ -7,7 +7,7 @@
#
# To enable this hook, rename this file to "pre-commit".
-if git-rev-parse --verify HEAD 2>/dev/null
+if git-rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
--
1.6.3.1.83.g37eb7
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pre-commit.sample: don't print incidental SHA1
2009-05-16 10:21 [PATCH] pre-commit.sample: don't print incidental SHA1 Jim Meyering
@ 2009-05-16 19:12 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2009-05-16 19:12 UTC (permalink / raw)
To: Jim Meyering; +Cc: git list
Jim Meyering <jim@meyering.net> writes:
> I enabled the sample pre-commit hook and was surprised to
> see new output with every commit. It was due to that script's
> use of git-rev-parse.
Thanks. I am half surprised that nobody has complained about this,
because the problem has been there since early 2006, and am half
unsurprised because I have long suspected that nobody would be using
pre-commit hook in real life.
> Also, I noticed the use of "git-hyphen" git-rev-parse.
> Perhaps that hyphen has been left in deliberately,
> for portability to very old versions of git?
Sample hooks do use features available only in the version of git that
ships them; we do not strive to retain such a portability in that sense.
The hook scripts are special in that they are invoked in an environment in
which the git subcommands in their dashed form are always available on its
$PATH. People tend to learn by looking at examples, so it is a good idea
to change them to use the new, separate subcommand, form to set examples.
But that is obviously a much wider patch, so let's make that a separate
issue.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-16 19:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-16 10:21 [PATCH] pre-commit.sample: don't print incidental SHA1 Jim Meyering
2009-05-16 19:12 ` Junio C Hamano
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 NNTP newsgroup(s).