{"thread":{"id":"57892","subject":"[PATCH] templates: clarify SHA1 arg in prepare-commit-msg","startedAt":"2022-05-18T18:40:26Z","lastAt":"2022-05-18T18:58:58Z","messageCount":2,"participants":["mataha via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"455412","messageId":"pull.1265.git.git.1652899219597.gitgitgadget@gmail.com","threadId":"57892","inReplyTo":null,"subject":"[PATCH] templates: clarify SHA1 arg in prepare-commit-msg","fromName":"mataha via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-05-18T18:40:19Z","receivedAt":"2022-05-18T18:40:26Z","isPatch":true,"sender":{"key":"name:mataha","avatar":null},"body":"From: mataha <mateusz.kazimierczuk@xolv.io>\n\n'prepare-commit-msg' hook sample description doesn't mention the third\nargument (a commit object name) nor when is it actually passed to that\nhook by git-commit (if the source is a commit; see builtin/commit.c#L777,\nsequencer.c#L1219). Seeing that it's documented in githooks(5), there\nshould be no reason not to include that in the sample hook as well.\n\nSigned-off-by: Mateusz 'mataha' Kazimierczuk <mateusz.kazimierczuk@xolv.io>\n---\n    Mention the third argument in 'prepare-commit-msg' hook sample\n    \n    'prepare-commit-msg' hook sample doesn't mention what the third argument\n    is for nor when is it actually passed; I feel like it should be, for the\n    sake of convenience (this doesn't mean that a user shouldn't refer to a\n    more detailed description in the manual, of course).\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1265%2Fmataha%2Fdoc%2Fprepare-commit-msg-args-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1265/mataha/doc/prepare-commit-msg-args-v1\nPull-Request: https://github.com/git/git/pull/1265\n\n templates/hooks--prepare-commit-msg.sample | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/templates/hooks--prepare-commit-msg.sample b/templates/hooks--prepare-commit-msg.sample\nindex 318afe3fd86..bc06d0701a8 100755\n--- a/templates/hooks--prepare-commit-msg.sample\n+++ b/templates/hooks--prepare-commit-msg.sample\n@@ -3,9 +3,9 @@\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 # 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,\n-# the commit is aborted.\n+# message's source and the commit object name (if the source was\n+# a commit).  The hook's purpose is to edit the commit message file.\n+# If the hook fails with a non-zero status, the commit is aborted.\n #\n # To enable this hook, rename this file to \"prepare-commit-msg\".\n \n\nbase-commit: 277cf0bc36094f6dc4297d8c9cef79df045b735d\n-- \ngitgitgadget\n"},{"id":"455414","messageId":"xmqqtu9mvfa1.fsf@gitster.g","threadId":"57892","inReplyTo":"pull.1265.git.git.1652899219597.gitgitgadget@gmail.com","subject":"Re: [PATCH] templates: clarify SHA1 arg in prepare-commit-msg","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-05-18T18:58:46Z","receivedAt":"2022-05-18T18:58:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Welcome to the development community.\n\n\"mataha via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: mataha <mateusz.kazimierczuk@xolv.io>\n\nThe name here must match the name you sign the patch off as,\ni.e. this line should read\n\n    From: Mateusz 'mataha' Kazimierczuk <mateusz.kazimierczuk@xolv.io>\n\n> 'prepare-commit-msg' hook sample description doesn't mention the third\n> argument (a commit object name) nor when is it actually passed to that\n> hook by git-commit (if the source is a commit; see builtin/commit.c#L777,\n> sequencer.c#L1219). Seeing that it's documented in githooks(5), there\n> should be no reason not to include that in the sample hook as well.\n\nThere should be a mention of the commit that added the hook, namely,\n8089c85b (git-commit: add a prepare-commit-msg hook, 2008-02-05).\nThe log message for this patch should also observe that this third\nargument, which is given only when the source is 'commit', was not\nmentioned in the sample hook added by the original commit.\n\nInterestingly, its log message reads:\n\n    ...\n    Its purpose is to modify the commit message in-place.\n\n    It takes one to three parameters.  The first is the name of the file that\n    the commit log message.  The second is the source of the commit message,\n    and can be: \"message\" (if a -m or -F option was given); \"template\" (if a\n    -t option was given or the configuration option commit.template is set);\n    \"merge\" (if the commit is a merge or a .git/MERGE_MSG file exists);\n    \"squash\" (if a .git/SQUASH_MSG file exists); or \"commit\", followed by\n    a commit SHA1 as the third parameter (if a -c, -C or --amend option\n    was given).\n    ...\n\nSo it wasn't a mistake that the sample did not mention it.  I think\nthe reason why the original, and today's version, does not mention\nit is because no sample code in the file actually uses it.\n\nI am not yet convinced that it is a good idea to only add mention to\nthe third one if we are not showing how it is used to this file,\nespecially given that in the documentation we _do_ cover these\narguments fully.\n\nThanks.\n\n> Signed-off-by: Mateusz 'mataha' Kazimierczuk <mateusz.kazimierczuk@xolv.io>\n> ---\n>     Mention the third argument in 'prepare-commit-msg' hook sample\n>     \n>     'prepare-commit-msg' hook sample doesn't mention what the third argument\n>     is for nor when is it actually passed; I feel like it should be, for the\n>     sake of convenience (this doesn't mean that a user shouldn't refer to a\n>     more detailed description in the manual, of course).\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1265%2Fmataha%2Fdoc%2Fprepare-commit-msg-args-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1265/mataha/doc/prepare-commit-msg-args-v1\n> Pull-Request: https://github.com/git/git/pull/1265\n>\n>  templates/hooks--prepare-commit-msg.sample | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n>\n> diff --git a/templates/hooks--prepare-commit-msg.sample b/templates/hooks--prepare-commit-msg.sample\n> index 318afe3fd86..bc06d0701a8 100755\n> --- a/templates/hooks--prepare-commit-msg.sample\n> +++ b/templates/hooks--prepare-commit-msg.sample\n> @@ -3,9 +3,9 @@\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>  # 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,\n> -# the commit is aborted.\n> +# message's source and the commit object name (if the source was\n> +# a commit).  The hook's purpose is to edit the commit message file.\n> +# If the hook fails with a non-zero status, the commit is aborted.\n>  #\n>  # To enable this hook, rename this file to \"prepare-commit-msg\".\n>  \n>\n> base-commit: 277cf0bc36094f6dc4297d8c9cef79df045b735d\n"}]}