{"thread":{"id":"19382","subject":"[PATCH] pre-commit.sample: don't print incidental SHA1","startedAt":"2009-05-16T10:21:50Z","lastAt":"2009-05-16T19:12:43Z","messageCount":2,"participants":["Jim Meyering","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"114089","messageId":"87y6sx1h6p.fsf@meyering.net","threadId":"19382","inReplyTo":null,"subject":"[PATCH] pre-commit.sample: don't print incidental SHA1","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2009-05-16T10:21:50Z","receivedAt":"2009-05-16T10:21:50Z","isPatch":true,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"\nMake the sample pre-commit hook script discard\nall git-rev-parse output, not just stderr.\nOtherwise, it would print an SHA1.\n\nSigned-off-by: Jim Meyering <meyering@redhat.com>\n---\n[this patch applies at least to \"next\"]\nI enabled the sample pre-commit hook and was surprised to\nsee new output with every commit.  It was due to that script's\nuse of git-rev-parse.\n\nAlso, I noticed the use of \"git-hyphen\" git-rev-parse.\nPerhaps that hyphen has been left in deliberately,\nfor portability to very old versions of git?\n\nWhile the 800+ uses of \"git rev-parse\" far outnumber uses of the\ntwo-hyphen version, this is far from being the only use in code\n(this is on the \"next\" branch):\n\n  $ git grep -l git-rev-parse|grep -vE 'Docu|command-list|\\.giti'\n  contrib/emacs/git.el\n  contrib/examples/git-revert.sh\n  git-archimport.perl\n  git-cvsexportcommit.perl\n  git-cvsimport.perl\n  git-submodule.sh\n  gitweb/gitweb.perl\n  perl/Git.pm\n  templates/hooks--pre-commit.sample\n\n\n templates/hooks--pre-commit.sample |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample\nindex 0e49279..0ba6207 100755\n--- a/templates/hooks--pre-commit.sample\n+++ b/templates/hooks--pre-commit.sample\n@@ -7,7 +7,7 @@\n #\n # To enable this hook, rename this file to \"pre-commit\".\n\n-if git-rev-parse --verify HEAD 2>/dev/null\n+if git-rev-parse --verify HEAD >/dev/null 2>&1\n then\n \tagainst=HEAD\n else\n-- \n1.6.3.1.83.g37eb7\n"},{"id":"114112","messageId":"7vvdo0n9p0.fsf@alter.siamese.dyndns.org","threadId":"19382","inReplyTo":"87y6sx1h6p.fsf@meyering.net","subject":"Re: [PATCH] pre-commit.sample: don't print incidental SHA1","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-16T19:12:43Z","receivedAt":"2009-05-16T19:12:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jim Meyering <jim@meyering.net> writes:\n\n> I enabled the sample pre-commit hook and was surprised to\n> see new output with every commit.  It was due to that script's\n> use of git-rev-parse.\n\nThanks.  I am half surprised that nobody has complained about this,\nbecause the problem has been there since early 2006, and am half\nunsurprised because I have long suspected that nobody would be using\npre-commit hook in real life.\n\n> Also, I noticed the use of \"git-hyphen\" git-rev-parse.\n> Perhaps that hyphen has been left in deliberately,\n> for portability to very old versions of git?\n\nSample hooks do use features available only in the version of git that\nships them; we do not strive to retain such a portability in that sense.\n\nThe hook scripts are special in that they are invoked in an environment in\nwhich the git subcommands in their dashed form are always available on its\n$PATH.  People tend to learn by looking at examples, so it is a good idea\nto change them to use the new, separate subcommand, form to set examples.\n\nBut that is obviously a much wider patch, so let's make that a separate\nissue.\n"}]}