{"thread":{"id":"31873","subject":"[PATCH] contrib/hooks: avoid requiring root access in usage instructions","startedAt":"2012-10-20T00:31:04Z","lastAt":"2012-10-20T07:03:11Z","messageCount":3,"participants":["Jonathan Nieder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"201584","messageId":"20121020003104.GA26596@elie.Belkin","threadId":"31873","inReplyTo":null,"subject":"[PATCH] contrib/hooks: avoid requiring root access in usage instructions","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-10-20T00:31:04Z","receivedAt":"2012-10-20T00:31:04Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Comments in hooks/post-receive-email suggest:\n\n For example, on debian the hook is stored in\n /usr/share/git-core/contrib/hooks/post-receive-email:\n\n  chmod a+x post-receive-email\n  cd /path/to/your/repository.git\n  ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive\n\nDoing that means changing permissions on a file provided by a package,\nwhich is problematic in a number of ways: the permissions would be\nlikely to change back in later upgrades, and changing them requires\nroot access.  Copying the script into each repo that uses it is not\nmuch better, since each copy would be maintained separately and not\nbenefit from bugfixes in the master copy.\n\nBetter to ship the hook with executable permission and remove the\nchmod line so enabling the hook becomes a one-step process: just\nsymlink it into place.\n\nLikewise for the pre-auto-gc-battery hook.\n\nReported-by: Olivier Berger <olivier.berger@it-sudparis.eu>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nFrom <http://bugs.debian.org/687391>.\n\nThoughts?\nJonathan\n\n contrib/hooks/post-receive-email  | 1 -\n contrib/hooks/pre-auto-gc-battery | 1 -\n 2 files changed, 2 deletions(-)\n mode change 100644 => 100755 contrib/hooks/pre-auto-gc-battery\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 8ca6607a..359f1ad2 100755\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -13,7 +13,6 @@\n # For example, on debian the hook is stored in\n # /usr/share/git-core/contrib/hooks/post-receive-email:\n #\n-#  chmod a+x post-receive-email\n #  cd /path/to/your/repository.git\n #  ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive\n #\ndiff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery\nold mode 100644\nnew mode 100755\nindex 1f914c94..9d0c2d19\n--- a/contrib/hooks/pre-auto-gc-battery\n+++ b/contrib/hooks/pre-auto-gc-battery\n@@ -13,7 +13,6 @@\n # For example, if the hook is stored in\n # /usr/share/git-core/contrib/hooks/pre-auto-gc-battery:\n #\n-# chmod a+x pre-auto-gc-battery\n # cd /path/to/your/repository.git\n # ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \\\n #\thooks/pre-auto-gc\n-- \n1.8.0.rc2\n"},{"id":"201586","messageId":"7vzk3hhj1m.fsf@alter.siamese.dyndns.org","threadId":"31873","inReplyTo":"20121020003104.GA26596@elie.Belkin","subject":"Re: [PATCH] contrib/hooks: avoid requiring root access in usage instructions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-20T04:19:33Z","receivedAt":"2012-10-20T04:19:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Comments in hooks/post-receive-email suggest:\n>\n>  For example, on debian the hook is stored in\n>  /usr/share/git-core/contrib/hooks/post-receive-email:\n>\n>   chmod a+x post-receive-email\n>   cd /path/to/your/repository.git\n>   ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive\n>\n> Doing that means changing permissions on a file provided by a package,\n> which is problematic in a number of ways: the permissions would be\n> likely to change back in later upgrades, and changing them requires\n> root access.  Copying the script into each repo that uses it is not\n> much better, since each copy would be maintained separately and not\n> benefit from bugfixes in the master copy.\n>\n> Better to ship the hook with executable permission and remove the\n> chmod line so enabling the hook becomes a one-step process: just\n> symlink it into place.\n>\n> Likewise for the pre-auto-gc-battery hook.\n>\n> Reported-by: Olivier Berger <olivier.berger@it-sudparis.eu>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n> From <http://bugs.debian.org/687391>.\n>\n> Thoughts?\n\nWe already encourage casting-in-stone a particular version of the\nsample hook when a new repository is created by copying them from\nthe template directory.  This prevents from surprising users when an\nupdated version of Git changes the behaviour of these samples.  Even\nif you think bugs in older ones may be corrected in newer ones,\nsilently updating the hook the user chose to use by inspecting one\nparticular version is not something we would want to do lightly. A\nbuggy devil you know is better than a devil that suddenly changes\nits behaviour depending on when your sysadmin updates the version of\nGit without your knowing.\n\nI personally think the same applies to these contrib/ hooks, and I\nwould think it is simpler and more consistent to correct the\ninstruction in these files to tell users to copy them.\n\nAdding +x bits to these files is a good idea but that is orthogonal\nto copying vs symlinking, I think.\n\n> Jonathan\n>\n>  contrib/hooks/post-receive-email  | 1 -\n>  contrib/hooks/pre-auto-gc-battery | 1 -\n>  2 files changed, 2 deletions(-)\n>  mode change 100644 => 100755 contrib/hooks/pre-auto-gc-battery\n>\n> diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\n> index 8ca6607a..359f1ad2 100755\n> --- a/contrib/hooks/post-receive-email\n> +++ b/contrib/hooks/post-receive-email\n> @@ -13,7 +13,6 @@\n>  # For example, on debian the hook is stored in\n>  # /usr/share/git-core/contrib/hooks/post-receive-email:\n>  #\n> -#  chmod a+x post-receive-email\n>  #  cd /path/to/your/repository.git\n>  #  ln -sf /usr/share/git-core/contrib/hooks/post-receive-email hooks/post-receive\n>  #\n> diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery\n> old mode 100644\n> new mode 100755\n> index 1f914c94..9d0c2d19\n> --- a/contrib/hooks/pre-auto-gc-battery\n> +++ b/contrib/hooks/pre-auto-gc-battery\n> @@ -13,7 +13,6 @@\n>  # For example, if the hook is stored in\n>  # /usr/share/git-core/contrib/hooks/pre-auto-gc-battery:\n>  #\n> -# chmod a+x pre-auto-gc-battery\n>  # cd /path/to/your/repository.git\n>  # ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \\\n>  #\thooks/pre-auto-gc\n"},{"id":"201587","messageId":"20121020070311.GB17969@elie.Belkin","threadId":"31873","inReplyTo":"7vzk3hhj1m.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] contrib/hooks: avoid requiring root access in usage instructions","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-10-20T07:03:11Z","receivedAt":"2012-10-20T07:03:11Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> We already encourage casting-in-stone a particular version of the\n> sample hook when a new repository is created by copying them from\n> the template directory.  This prevents from surprising users when an\n> updated version of Git changes the behaviour of these samples.  Even\n> if you think bugs in older ones may be corrected in newer ones,\n> silently updating the hook the user chose to use by inspecting one\n> particular version is not something we would want to do lightly.\n\nFor context, the sample hooks you are talking about are the *.sample\nfiles from the templates/ directory.  Except for post-update.sample,\nmost are not very useful out of the box, and they are very much\nintended as examples to start people's thinking, as opposed to\nsomething one-size-fits-all.\n\nBy contrast, the post-receive-email script from contrib is a complete\nprogram with a well-defined behavior and configuration that have\nstayed consistent while the details of its implementation improved.\nIt can be used by symlinking into place, but maybe a better set of\ninstructions would say\n\n\t# This script takes no arguments and expects the same input format\n\t# as git's post-receive hook, so if this script is at\n\t# /usr/share/git-core/contrib/hooks/post-receive-email (as it is\n\t# on Debian and Fedora), you can do\n\t#\n\t#  cd /path/to/your/repository.git\n\t#  echo '#!/bin/sh' >hooks/post-receive\n\t#  echo 'exec /usr/share/git-core/contrib/hooks/post-receive-email' \\\n\t#\t>>hooks/post-receive\n\t#  chmod +x hooks/post-receive\n\nThat would make it more obvious what I can do next if my post-receive\ninput should be passed both to post-receive-email and some other tool\n(perhaps in a pipeline using \"tee\").\n\nHmm?\nJonathan\n"}]}