{"thread":{"id":"6047","subject":"Re: [PATCH] hooks/pre-commit: add example to add Signed-off-by line to message","startedAt":"2006-11-29T11:20:08Z","lastAt":"2006-12-22T09:28:07Z","messageCount":11,"participants":["Johannes Schindelin","Andy Parkins","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"295063","messageId":"Pine.LNX.4.63.0611291219190.30004@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6047","inReplyTo":null,"subject":"[PATCH] hooks/pre-commit: add example to add Signed-off-by line to message","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-11-29T11:20:08Z","receivedAt":"2006-11-29T11:20:08Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nIt is good to have an example of how to supply a template for the\ncommit message anyway.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n templates/hooks--pre-commit |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit\nindex 723a9ef..931f127 100644\n--- a/templates/hooks--pre-commit\n+++ b/templates/hooks--pre-commit\n@@ -7,6 +7,13 @@\n #\n # To enable this hook, make this file executable.\n \n+# Uncomment this to add a Signed-off-by line to the message.\n+\n+# . git-sh-setup\n+# git var GIT_AUTHOR_IDENT | \\\n+# sed -n \"s/^\\(.*\\) [0-9]\\+ [-+][0-9]\\+$/Signed-off-by: \\1/p\" \\\n+# > $GIT_DIR/SQUASH_MSG\n+\n # This is slightly modified from Andrew Morton's Perfect Patch.\n # Lines you introduce should not have trailing whitespace.\n # Also check for an indentation that has SP before a TAB.\n-- \n1.4.4.1.gb475\n"},{"id":"295631","messageId":"200612201554.52553.andyparkins@gmail.com","threadId":"6047","inReplyTo":"Pine.LNX.4.63.0611291219190.30004@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] hooks/pre-commit: add example to add Signed-off-by line to message","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-20T15:54:51Z","receivedAt":"2006-12-20T15:54:51Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Wednesday 2006 November 29 11:20, Johannes Schindelin wrote:\n\n> +# . git-sh-setup\n> +# git var GIT_AUTHOR_IDENT | \\\n> +# sed -n \"s/^\\(.*\\) [0-9]\\+ [-+][0-9]\\+$/Signed-off-by: \\1/p\" \\\n> +# > $GIT_DIR/SQUASH_MSG\n\nI've been using this; and very useful it is too.  However, I just noticed that \nI was getting \"Not a git repository\" errors when I tried to commit in a \nsubdirectory.  I traced the problem to my use of this fragment.  It seems \nthat calling git-sh-setup inside the pre-commit hook was changing GIT_DIR \n(don't know why).  When I changed this to\n\ngit var GIT_AUTHOR_IDENT | \\\nsed -n \"s/^\\(.*\\) [0-9]\\+ [-+][0-9]\\+$/Signed-off-by: \\1/p\" \\\n >> $(git-rev-parse --git-dir)/SQUASH_MSG\n\nIt worked correctly again.\n\n\nAndy\n\n\n-- \nDr Andy Parkins, M Eng (hons), MIEE\n"},{"id":"297626","messageId":"200612201604.12498.andyparkins@gmail.com","threadId":"6047","inReplyTo":"Pine.LNX.4.63.0611291219190.30004@wbgn013.biozentrum.uni-wuerzburg.de","subject":"[PATCH] hooks/pre-commit: add example to add Signed-off-by line to message","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-20T16:04:12Z","receivedAt":"2006-12-20T16:04:12Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"Based on Johannes Schindelin's earlier patch to perform the same\nfunction.\n\nThe call to git-sh-setup was causing \"Not a git repository\" errors after\nthe pre-commit script had run.  I removed the call and used\n$(git-rev-parse --git-dir) instead, which seems to have fixed the\nproblem.\n\nSigned-off-by: Andy Parkins <andyparkins@gmail.com>\n---\n templates/hooks--pre-commit |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit\nindex 723a9ef..87d9ccc 100644\n--- a/templates/hooks--pre-commit\n+++ b/templates/hooks--pre-commit\n@@ -7,6 +7,11 @@\n #\n # To enable this hook, make this file executable.\n \n+# Uncomment the below to add a Signed-off-by line to the message.\n+#git var GIT_AUTHOR_IDENT | \\\n+#sed -n \"s/^\\(.*\\) [0-9]\\+ [-+][0-9]\\+$/Signed-off-by: \\1/p\" \\\n+# >> $(git-rev-parse --git-dir)/SQUASH_MSG\n+\n # This is slightly modified from Andrew Morton's Perfect Patch.\n # Lines you introduce should not have trailing whitespace.\n # Also check for an indentation that has SP before a TAB.\n-- \n1.4.4.2.g120e3\n"},{"id":"293925","messageId":"Pine.LNX.4.63.0612201717490.19693@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6047","inReplyTo":"200612201604.12498.andyparkins@gmail.com","subject":"Re: [PATCH] hooks/pre-commit: add example to add Signed-off-by line to message","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-20T16:18:30Z","receivedAt":"2006-12-20T16:18:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 20 Dec 2006, Andy Parkins wrote:\n\n> Signed-off-by: Andy Parkins <andyparkins@gmail.com>\n\nAcked-by: Johannes E. Schindelin <johannes.schindelin@gmx.de>\n\nCiao,\nDscho\n"},{"id":"296522","messageId":"7vmz5ifpbv.fsf@assigned-by-dhcp.cox.net","threadId":"6047","inReplyTo":"Pine.LNX.4.63.0612201717490.19693@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] hooks/pre-commit: add example to add Signed-off-by line to message","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-20T17:29:40Z","receivedAt":"2006-12-20T17:29:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi,\n>\n> On Wed, 20 Dec 2006, Andy Parkins wrote:\n>\n>> Signed-off-by: Andy Parkins <andyparkins@gmail.com>\n>\n> Acked-by: Johannes E. Schindelin <johannes.schindelin@gmx.de>\n>\n> Ciao,\n> Dscho\n\nWhy SQUASH_MSG?  Doesn't it confuse git-explain when it wants to\ndetect that you are in the middle of a squash merge?\n"},{"id":"297067","messageId":"Pine.LNX.4.63.0612201835570.19693@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6047","inReplyTo":"7vmz5ifpbv.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] hooks/pre-commit: add example to add Signed-off-by line to message","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-20T17:37:45Z","receivedAt":"2006-12-20T17:37:45Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 20 Dec 2006, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > Hi,\n> >\n> > On Wed, 20 Dec 2006, Andy Parkins wrote:\n> >\n> >> Signed-off-by: Andy Parkins <andyparkins@gmail.com>\n> >\n> > Acked-by: Johannes E. Schindelin <johannes.schindelin@gmx.de>\n> >\n> > Ciao,\n> > Dscho\n> \n> Why SQUASH_MSG?  Doesn't it confuse git-explain when it wants to\n> detect that you are in the middle of a squash merge?\n\nYes, it confuses git-explain. Which did not existed when I concocted the \nfirst (broken) version of this patch. There are only two ways to give \ncommit message templates AFAICT: misusing SQUASH_MSG and misusing \nMERGE_MSG.\n\nCiao,\nDscho\n"},{"id":"296762","messageId":"7vejqufonm.fsf@assigned-by-dhcp.cox.net","threadId":"6047","inReplyTo":"Pine.LNX.4.63.0612201835570.19693@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] hooks/pre-commit: add example to add Signed-off-by line to message","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-20T17:44:13Z","receivedAt":"2006-12-20T17:44:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> Why SQUASH_MSG?  Doesn't it confuse git-explain when it wants to\n>> detect that you are in the middle of a squash merge?\n>\n> Yes, it confuses git-explain. Which did not existed when I concocted the \n> first (broken) version of this patch. There are only two ways to give \n> commit message templates AFAICT: misusing SQUASH_MSG and misusing \n> MERGE_MSG.\n\nI wonder...\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# 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.\n\n"},{"id":"29907","messageId":"Pine.LNX.4.63.0612210925400.19693@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6047","inReplyTo":"7vejqufonm.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] hooks/pre-commit: add example to add Signed-off-by line to message","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-21T08:26:49Z","receivedAt":"2006-12-21T08:26:49Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 20 Dec 2006, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> >> Why SQUASH_MSG?  Doesn't it confuse git-explain when it wants to\n> >> detect that you are in the middle of a squash merge?\n> >\n> > Yes, it confuses git-explain. Which did not existed when I concocted the \n> > first (broken) version of this patch. There are only two ways to give \n> > commit message templates AFAICT: misusing SQUASH_MSG and misusing \n> > MERGE_MSG.\n> \n> I wonder...\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> # 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.\n\nYes, I missed that.\n\nCiao,\nDscho\n"},{"id":"29922","messageId":"200612210924.17357.andyparkins@gmail.com","threadId":"6047","inReplyTo":"7vejqufonm.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] hooks/commit-msg: add example to add Signed-off-by line to message","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-21T09:24:17Z","receivedAt":"2006-12-21T09:24:17Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"After checking to see if the commit message already has the target\nsigned-off-by (for example in --amend commits), this patch generates a\nsigned off by line from the repository owner and adds it to the commit\nmessage.\n\nBased on Johannes Schindelin's earlier patch to perform the same\nfunction.\n\nOriginally, this was done in the pre-commit hook but Junio pointed out\nthat the commit-msg hook allows the message to be edited.  This has the\naditional advantage that the commit-msg hook gets passed the name of the\nmessage file as a parameter, so it doesn't have to figure out GIT_DIR for\nitself.\n\nSigned-off-by: Andy Parkins <andyparkins@gmail.com>\n---\n templates/hooks--commit-msg |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg\nindex 0b906ca..ce76bdf 100644\n--- a/templates/hooks--commit-msg\n+++ b/templates/hooks--commit-msg\n@@ -8,6 +8,11 @@\n #\n # To enable this hook, make this file executable.\n \n+# Uncomment the below to add a Signed-off-by line to the message.\n+#SOB=$(git var GIT_AUTHOR_IDENT | \\\n+#\tsed -n \"s/^\\(.*\\) [0-9]\\+ [-+][0-9]\\+$/Signed-off-by: \\1/p\")\n+#grep -qs \"^$SOB\" \"$1\" || echo \"$SOB\" >> \"$1\"\n+\n # This example catches duplicate Signed-off-by lines.\n \n test \"\" = \"$(grep '^Signed-off-by: ' \"$1\" |\n-- \n1.4.4.2.g120e3\n"},{"id":"30014","messageId":"7v64c47abv.fsf@assigned-by-dhcp.cox.net","threadId":"6047","inReplyTo":"200612210924.17357.andyparkins@gmail.com","subject":"Re: [PATCH] hooks/commit-msg: add example to add Signed-off-by line to message","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-22T05:45:24Z","receivedAt":"2006-12-22T05:45:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Parkins <andyparkins@gmail.com> writes:\n\n> +# Uncomment the below to add a Signed-off-by line to the message.\n> +#SOB=$(git var GIT_AUTHOR_IDENT | \\\n> +#\tsed -n \"s/^\\(.*\\) [0-9]\\+ [-+][0-9]\\+$/Signed-off-by: \\1/p\")\n> +#grep -qs \"^$SOB\" \"$1\" || echo \"$SOB\" >> \"$1\"\n\nI suspect this sed script is quite wrong.  Did you test it?\n\n * quoting with dq means you are losing one level of backslash\n   to the shell and sed is not seeing them.\n\n * one-or-more regexp '+' is typically not found in sed.\n\nAlso if this is meant to also handle cases where somebody\ncommits a patch received from an e-mail chain that multiple\npeople signed off their own changes to the patch, your name may\nalready appear earlier in the chain of existing Signed-off-by:\nlines to sign off an earlier edition of the patch, but what you\nare committing now would include your own changes you just made\non top of what all these people did, and you would want to sign\noff that new change as well, I think.  So checking the last\ninstance of the existing signed-off-by line, ignoring earlier\nones, may be more preferrable.\n"},{"id":"30035","messageId":"200612220928.08921.andyparkins@gmail.com","threadId":"6047","inReplyTo":"7v64c47abv.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] hooks/commit-msg: add example to add Signed-off-by line to message","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-22T09:28:07Z","receivedAt":"2006-12-22T09:28:07Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Friday 2006 December 22 05:45, Junio C Hamano wrote:\n\n> I suspect this sed script is quite wrong.  Did you test it?\n\nI plead not guilty; cut and pasted from Johannes.  In it's defence; I've been \nusing it since he gave it to me without trouble.  My patch is wrapping it a \nlittle differently, but the sed is certainly the same.\n\nAmazingly it does work though...\n\n>  * quoting with dq means you are losing one level of backslash\n>    to the shell and sed is not seeing them.\n\nUnusual.  It doesn't seem to apply to non-recognised escapes:\n\n$ echo \"\\1\\(\\)\\+$/\"\n\\1\\(\\)\\+$/\n\n>  * one-or-more regexp '+' is typically not found in sed.\n\nSeems to be in mine (GNU sed version 4.1.5).\n\n$ echo \"xxxxxx\" | sed -n 's/\\(x\\+\\)$/MATCH/p'\nMATCH\n\n> off that new change as well, I think.  So checking the last\n> instance of the existing signed-off-by line, ignoring earlier\n> ones, may be more preferrable.\n\nAccepted.\n\nNotwithstanding the fact that it seems to be working for me; I'll fix the \nproblems you highlight and re-patch.\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIEE\nandyparkins@gmail.com\n"}]}