{"thread":{"id":"23107","subject":"[PATCH 0/2] Template cleanups","startedAt":"2010-03-20T14:48:07Z","lastAt":"2010-03-20T14:48:09Z","messageCount":3,"participants":["Ben Walton"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"137333","messageId":"1269096489-12750-1-git-send-email-bwalton@artsci.utoronto.ca","threadId":"23107","inReplyTo":null,"subject":"[PATCH 0/2] Template cleanups","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2010-03-20T14:48:07Z","receivedAt":"2010-03-20T14:48:07Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"Hi All,\n\nI noticed that the template sample hooks were a) using shell\nconventions that may not work under /bin/sh on all platforms and b)\nusing the old git-foo calling conventions in some, but not all, cases.\nThe following two patches rectify this.\n\nThe build system will now substitute SHELL_PATH and PERL_PATH into\nfiles under templates/ so that the templates use the same tools as the\nrest of git.\n\nBen Walton (2):\n  Make templates honour SHELL_PATH and PERL_PATH\n  Modernize git calling conventions in hook templates\n\n Makefile                                   |    2 +-\n templates/Makefile                         |   17 +++++++++++++++--\n templates/hooks--commit-msg.sample         |    2 +-\n templates/hooks--post-update.sample        |    2 +-\n templates/hooks--pre-commit.sample         |    4 ++--\n templates/hooks--pre-rebase.sample         |   20 ++++++++++----------\n templates/hooks--prepare-commit-msg.sample |    6 +++---\n templates/hooks--update.sample             |    4 ++--\n templates/info--exclude                    |    2 +-\n 9 files changed, 36 insertions(+), 23 deletions(-)\n"},{"id":"137334","messageId":"1269096489-12750-2-git-send-email-bwalton@artsci.utoronto.ca","threadId":"23107","inReplyTo":"1269096489-12750-1-git-send-email-bwalton@artsci.utoronto.ca","subject":"[PATCH 1/2] Make templates honour SHELL_PATH and PERL_PATH","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2010-03-20T14:48:08Z","receivedAt":"2010-03-20T14:48:08Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"The hook script templates were hard coded to use /bin/sh and perl.\nThis patch ensures that they use the same tools specified for the rest\nof the suite.\n\nThe impetus for the change was noticing that, as shipped, some of the\nhooks used shell constructs that wouldn't work under Solaris' /bin/sh\n(eg: $(cmd...) substitutions).\n\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\n Makefile                                   |    2 +-\n templates/Makefile                         |   17 +++++++++++++++--\n templates/hooks--pre-rebase.sample         |    2 +-\n templates/hooks--prepare-commit-msg.sample |    4 ++--\n 4 files changed, 19 insertions(+), 6 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 7c616f8..86638de 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1469,7 +1469,7 @@ endif\n ifndef NO_PYTHON\n \t$(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all\n endif\n-\t$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)\n+\t$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'\n \n please_set_SHELL_PATH_to_a_more_modern_shell:\n \t@$$(:)\ndiff --git a/templates/Makefile b/templates/Makefile\nindex 408f013..d22a71a 100644\n--- a/templates/Makefile\n+++ b/templates/Makefile\n@@ -11,6 +11,16 @@ prefix ?= $(HOME)\n template_instdir ?= $(prefix)/share/git-core/templates\n # DESTDIR=\n \n+ifndef SHELL_PATH\n+\tSHELL_PATH = /bin/sh\n+endif\n+ifndef PERL_PATH\n+\tPERL_PATH = perl\n+endif\n+\n+SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n+PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n+\n # Shell quote (do not use $(call) to accommodate ancient setups);\n DESTDIR_SQ = $(subst ','\\'',$(DESTDIR))\n template_instdir_SQ = $(subst ','\\'',$(template_instdir))\n@@ -33,8 +43,11 @@ boilerplates.made : $(bpsrc)\n \t\tcase \"$$boilerplate\" in \\\n \t\t*--) continue;; \\\n \t\tesac && \\\n-\t\tcp $$boilerplate blt/$$dst && \\\n-\t\tif test -x \"blt/$$dst\"; then rx=rx; else rx=r; fi && \\\n+\t\tsed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n+\t\t    -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \\\n+\t\t    -e 's|@PERL_PATH@|$(PERL_PATH_SQ)|g' $$boilerplate > \\\n+\t\t\tblt/$$dst && \\\n+\t\tif test -x \"$$boilerplate\"; then rx=rx; else rx=r; fi && \\\n \t\tchmod a+$$rx \"blt/$$dst\" || exit; \\\n \tdone && \\\n \tdate >$@\ndiff --git a/templates/hooks--pre-rebase.sample b/templates/hooks--pre-rebase.sample\nindex be1b06e..ab1c4c8 100755\n--- a/templates/hooks--pre-rebase.sample\n+++ b/templates/hooks--pre-rebase.sample\n@@ -65,7 +65,7 @@ then\n \tfi\n else\n \tnot_in_next=`git-rev-list --pretty=oneline ^${publish} \"$topic\"`\n-\tperl -e '\n+\t@PERL_PATH@ -e '\n \t\tmy $topic = $ARGV[0];\n \t\tmy $msg = \"* $topic has commits already merged to public branch:\\n\";\n \t\tmy (%not_in_next) = map {\ndiff --git a/templates/hooks--prepare-commit-msg.sample b/templates/hooks--prepare-commit-msg.sample\nindex 3652424..e8d1754 100755\n--- a/templates/hooks--prepare-commit-msg.sample\n+++ b/templates/hooks--prepare-commit-msg.sample\n@@ -22,10 +22,10 @@\n \n case \"$2,$3\" in\n   merge,)\n-    perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' \"$1\" ;;\n+    @PERL_PATH@ -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' \"$1\" ;;\n \n # ,|template,)\n-#   perl -i.bak -pe '\n+#   @PERL_PATH@ -i.bak -pe '\n #      print \"\\n\" . `git diff --cached --name-status -r`\n #\t if /^#/ && $first++ == 0' \"$1\" ;;\n \n-- \n1.7.0\n"},{"id":"137335","messageId":"1269096489-12750-3-git-send-email-bwalton@artsci.utoronto.ca","threadId":"23107","inReplyTo":"1269096489-12750-1-git-send-email-bwalton@artsci.utoronto.ca","subject":"[PATCH 2/2] Modernize git calling conventions in hook templates","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2010-03-20T14:48:09Z","receivedAt":"2010-03-20T14:48:09Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"The hook templates were still using/referencing 'git-foo' instead of\n'git foo.'  This patch updates the sample hooks to use the modern\nconventions instead.\n\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\n templates/hooks--commit-msg.sample         |    2 +-\n templates/hooks--post-update.sample        |    2 +-\n templates/hooks--pre-commit.sample         |    4 ++--\n templates/hooks--pre-rebase.sample         |   18 +++++++++---------\n templates/hooks--prepare-commit-msg.sample |    2 +-\n templates/hooks--update.sample             |    4 ++--\n templates/info--exclude                    |    2 +-\n 7 files changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/templates/hooks--commit-msg.sample b/templates/hooks--commit-msg.sample\nindex 6ef1d29..b58d118 100755\n--- a/templates/hooks--commit-msg.sample\n+++ b/templates/hooks--commit-msg.sample\n@@ -1,7 +1,7 @@\n #!/bin/sh\n #\n # An example hook script to check the commit log message.\n-# Called by git-commit with one argument, the name of the file\n+# Called by \"git commit\" with one argument, the name of the file\n # that has the commit message.  The hook should exit with non-zero\n # status after issuing an appropriate message if it wants to stop the\n # commit.  The hook is allowed to edit the commit message file.\ndiff --git a/templates/hooks--post-update.sample b/templates/hooks--post-update.sample\nindex 5323b56..ec17ec1 100755\n--- a/templates/hooks--post-update.sample\n+++ b/templates/hooks--post-update.sample\n@@ -5,4 +5,4 @@\n #\n # To enable this hook, rename this file to \"post-update\".\n \n-exec git-update-server-info\n+exec git update-server-info\ndiff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample\nindex 439eefd..b187c4b 100755\n--- a/templates/hooks--pre-commit.sample\n+++ b/templates/hooks--pre-commit.sample\n@@ -1,13 +1,13 @@\n #!/bin/sh\n #\n # An example hook script to verify what is about to be committed.\n-# Called by git-commit with no arguments.  The hook should\n+# Called by \"git commit\" with no arguments.  The hook should\n # exit with non-zero status after issuing an appropriate message if\n # it wants to stop the commit.\n #\n # To enable this hook, rename this file to \"pre-commit\".\n \n-if git-rev-parse --verify HEAD >/dev/null 2>&1\n+if git rev-parse --verify HEAD >/dev/null 2>&1\n then\n \tagainst=HEAD\n else\ndiff --git a/templates/hooks--pre-rebase.sample b/templates/hooks--pre-rebase.sample\nindex ab1c4c8..053f111 100755\n--- a/templates/hooks--pre-rebase.sample\n+++ b/templates/hooks--pre-rebase.sample\n@@ -2,7 +2,7 @@\n #\n # Copyright (c) 2006, 2008 Junio C Hamano\n #\n-# The \"pre-rebase\" hook is run just before \"git-rebase\" starts doing\n+# The \"pre-rebase\" hook is run just before \"git rebase\" starts doing\n # its job, and can prevent the command from running by exiting with\n # non-zero status.\n #\n@@ -43,7 +43,7 @@ git show-ref -q \"$topic\" || {\n }\n \n # Is topic fully merged to master?\n-not_in_master=`git-rev-list --pretty=oneline ^master \"$topic\"`\n+not_in_master=`git rev-list --pretty=oneline ^master \"$topic\"`\n if test -z \"$not_in_master\"\n then\n \techo >&2 \"$topic is fully merged to master; better remove it.\"\n@@ -51,11 +51,11 @@ then\n fi\n \n # Is topic ever merged to next?  If so you should not be rebasing it.\n-only_next_1=`git-rev-list ^master \"^$topic\" ${publish} | sort`\n-only_next_2=`git-rev-list ^master           ${publish} | sort`\n+only_next_1=`git rev-list ^master \"^$topic\" ${publish} | sort`\n+only_next_2=`git rev-list ^master           ${publish} | sort`\n if test \"$only_next_1\" = \"$only_next_2\"\n then\n-\tnot_in_topic=`git-rev-list \"^$topic\" master`\n+\tnot_in_topic=`git rev-list \"^$topic\" master`\n \tif test -z \"$not_in_topic\"\n \tthen\n \t\techo >&2 \"$topic is already up-to-date with master\"\n@@ -64,7 +64,7 @@ then\n \t\texit 0\n \tfi\n else\n-\tnot_in_next=`git-rev-list --pretty=oneline ^${publish} \"$topic\"`\n+\tnot_in_next=`git rev-list --pretty=oneline ^${publish} \"$topic\"`\n \t@PERL_PATH@ -e '\n \t\tmy $topic = $ARGV[0];\n \t\tmy $msg = \"* $topic has commits already merged to public branch:\\n\";\n@@ -157,13 +157,13 @@ B to be deleted.\n \n To compute (1):\n \n-\tgit-rev-list ^master ^topic next\n-\tgit-rev-list ^master        next\n+\tgit rev-list ^master ^topic next\n+\tgit rev-list ^master        next\n \n \tif these match, topic has not merged in next at all.\n \n To compute (2):\n \n-\tgit-rev-list master..topic\n+\tgit rev-list master..topic\n \n \tif this is empty, it is fully merged to \"master\".\ndiff --git a/templates/hooks--prepare-commit-msg.sample b/templates/hooks--prepare-commit-msg.sample\nindex e8d1754..86b8f22 100755\n--- a/templates/hooks--prepare-commit-msg.sample\n+++ b/templates/hooks--prepare-commit-msg.sample\n@@ -1,7 +1,7 @@\n #!/bin/sh\n #\n # An example hook script to prepare the commit log message.\n-# Called by git-commit with the name of the file that has the\n+# Called by \"git commit\" with the name of the file that has the\n # commit message, followed by the description of the commit\n # message's source.  The hook's purpose is to edit the commit\n # message file.  If the hook fails with a non-zero status,\ndiff --git a/templates/hooks--update.sample b/templates/hooks--update.sample\nindex fd63b2d..71ab04e 100755\n--- a/templates/hooks--update.sample\n+++ b/templates/hooks--update.sample\n@@ -1,7 +1,7 @@\n #!/bin/sh\n #\n # An example hook script to blocks unannotated tags from entering.\n-# Called by git-receive-pack with arguments: refname sha1-old sha1-new\n+# Called by \"git receive-pack\" with arguments: refname sha1-old sha1-new\n #\n # To enable this hook, rename this file to \"update\".\n #\n@@ -64,7 +64,7 @@ zero=\"0000000000000000000000000000000000000000\"\n if [ \"$newrev\" = \"$zero\" ]; then\n \tnewrev_type=delete\n else\n-\tnewrev_type=$(git-cat-file -t $newrev)\n+\tnewrev_type=$(git cat-file -t $newrev)\n fi\n \n case \"$refname\",\"$newrev_type\" in\ndiff --git a/templates/info--exclude b/templates/info--exclude\nindex 2c87b72..a5196d1 100644\n--- a/templates/info--exclude\n+++ b/templates/info--exclude\n@@ -1,4 +1,4 @@\n-# git-ls-files --others --exclude-from=.git/info/exclude\n+# git ls-files --others --exclude-from=.git/info/exclude\n # Lines that start with '#' are comments.\n # For a project mostly in C, the following would be a good set of\n # exclude patterns (uncomment them if you want to use them):\n-- \n1.7.0\n"}]}