{"thread":{"id":"30098","subject":"[PATCH] git-commit doc: say -t requires editing commit message","startedAt":"2012-03-29T17:57:56Z","lastAt":"2012-04-05T14:29:53Z","messageCount":19,"participants":["Adam Monsen","Ivan Heffner","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"188083","messageId":"1333043876-19966-1-git-send-email-haircut@gmail.com","threadId":"30098","inReplyTo":null,"subject":"[PATCH] git-commit doc: say -t requires editing commit message","fromName":"Adam Monsen","fromEmail":"haircut@gmail.com","sentAt":"2012-03-29T17:57:56Z","receivedAt":"2012-03-29T17:57:56Z","isPatch":true,"sender":{"key":"haircut@gmail.com","avatar":"https://avatars.githubusercontent.com/u/50639?v=4"},"body":"Make it clear that, when using a commit template, the message *must* be\nchanged or the commit will be aborted \"due to empty commit message\".\n\nSigned-off-by: Adam Monsen <haircut@gmail.com>\n---\n\nI found it confusing that the commit template itself, even if\nnon-empty, must be edited. Hopefully this clears that up a bit.\n\n Documentation/git-commit.txt |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 5cc84a1..44947ab 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -133,7 +133,7 @@ OPTIONS\n -t <file>::\n --template=<file>::\n \tUse the contents of the given file as the initial version\n-\tof the commit message. The editor is invoked and you can\n+\tof the commit message. The editor is invoked and you must\n \tmake subsequent changes. If a message is specified using\n \tthe `-m` or `-F` options, this option has no effect. This\n \toverrides the `commit.template` configuration variable.\n-- \n1.7.5.4\n"},{"id":"188085","messageId":"CAF_oF=xGHdbkYw-ytvcZvJnqZ_jdckUCBiuUDzkqGDk=66+yMQ@mail.gmail.com","threadId":"30098","inReplyTo":"1333043876-19966-1-git-send-email-haircut@gmail.com","subject":"Re: [PATCH] git-commit doc: say -t requires editing commit message","fromName":"Ivan Heffner","fromEmail":"iheffner@gmail.com","sentAt":"2012-03-29T18:09:48Z","receivedAt":"2012-03-29T18:09:48Z","isPatch":true,"sender":{"key":"iheffner@gmail.com","avatar":"https://gravatar.com/avatar/1ead000fad98fe337916f06edfc94fd87207ffc81a3a5363589e51c4f2bfa602?d=mp&s=160"},"body":"I'd suggest being much more verbose about what's going on and why.\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 5cc84a1..e842916 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -133,10 +133,12 @@ OPTIONS\n -t <file>::\n --template=<file>::\n        Use the contents of the given file as the initial version\n-       of the commit message. The editor is invoked and you can\n-       make subsequent changes. If a message is specified using\n-       the `-m` or `-F` options, this option has no effect. This\n-       overrides the `commit.template` configuration variable.\n+       of the commit message. The editor is invoked so you can\n+       make changes. If a message is specified using the `-m` or `-F`\n+       options, this option has no effect. This overrides the\n+       `commit.template` configuration variable. If the message is\n+       unchanged, the message is considered to be empty and the commit is\n+       aborted\n\n -s::\n --signoff::\n--\n1.7.6.553.g917d7.dirty\n\nOn Thu, Mar 29, 2012 at 10:57 AM, Adam Monsen <haircut@gmail.com> wrote:\n>\n> Make it clear that, when using a commit template, the message *must* be\n> changed or the commit will be aborted \"due to empty commit message\".\n>\n> Signed-off-by: Adam Monsen <haircut@gmail.com>\n> ---\n>\n> I found it confusing that the commit template itself, even if\n> non-empty, must be edited. Hopefully this clears that up a bit.\n>\n>  Documentation/git-commit.txt |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n>\n> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\n> index 5cc84a1..44947ab 100644\n> --- a/Documentation/git-commit.txt\n> +++ b/Documentation/git-commit.txt\n> @@ -133,7 +133,7 @@ OPTIONS\n>  -t <file>::\n>  --template=<file>::\n>        Use the contents of the given file as the initial version\n> -       of the commit message. The editor is invoked and you can\n> +       of the commit message. The editor is invoked and you must\n>        make subsequent changes. If a message is specified using\n>        the `-m` or `-F` options, this option has no effect. This\n>        overrides the `commit.template` configuration variable.\n> --\n> 1.7.5.4\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"188106","messageId":"1333062296-27823-1-git-send-email-haircut@gmail.com","threadId":"30098","inReplyTo":"CAF_oF=xGHdbkYw-ytvcZvJnqZ_jdckUCBiuUDzkqGDk=66+yMQ@mail.gmail.com","subject":"[PATCH v2] git-commit.txt: clarify -t requires editing message","fromName":"Adam Monsen","fromEmail":"haircut@gmail.com","sentAt":"2012-03-29T23:04:56Z","receivedAt":"2012-03-29T23:04:56Z","isPatch":true,"sender":{"key":"haircut@gmail.com","avatar":"https://avatars.githubusercontent.com/u/50639?v=4"},"body":"Make it clear that, when using a commit template, the message *must* be\nchanged or the commit will be aborted \"due to empty commit message\".\n\nHelped-by: Ivan Heffner <iheffner@gmail.com>\nSigned-off-by: Adam Monsen <haircut@gmail.com>\n---\nIncorporate feedback from Ivan Heffner.\n\nAnyone else agree/disagree with this patch? I would like to see the\nmanpage improved because I found the behavior of \"git commit -t\"\nconfusing as documented.\n\nI wrapped the text at 77 characters because that was the longest\nline in the file (according to wc -L).\n\nI used \":set noet nosta ts=8 sw=8 tw=77\" in Vim.\n\n Documentation/git-commit.txt |   10 ++++++----\n 1 files changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 5cc84a1..c6df120 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -133,10 +133,12 @@ OPTIONS\n -t <file>::\n --template=<file>::\n \tUse the contents of the given file as the initial version\n-\tof the commit message. The editor is invoked and you can\n-\tmake subsequent changes. If a message is specified using\n-\tthe `-m` or `-F` options, this option has no effect. This\n-\toverrides the `commit.template` configuration variable.\n+\tof the commit message. The editor is invoked so you can\n+\tmake subsequent changes. If you make no changes, the message\n+\tis considered empty and the commit is aborted. If a message\n+\tis specified using the `-m` or `-F` options, this option has\n+\tno effect. This overrides the `commit.template`\n+\tconfiguration variable.\n \n -s::\n --signoff::\n-- \n1.7.5.4\n"},{"id":"188114","messageId":"7vboneq1vs.fsf@alter.siamese.dyndns.org","threadId":"30098","inReplyTo":"1333062296-27823-1-git-send-email-haircut@gmail.com","subject":"Re: [PATCH v2] git-commit.txt: clarify -t requires editing message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-30T02:05:43Z","receivedAt":"2012-03-30T02:05:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Monsen <haircut@gmail.com> writes:\n\n> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\n> index 5cc84a1..c6df120 100644\n> --- a/Documentation/git-commit.txt\n> +++ b/Documentation/git-commit.txt\n> @@ -133,10 +133,12 @@ OPTIONS\n>  -t <file>::\n>  --template=<file>::\n>  \tUse the contents of the given file as the initial version\n> +\tof the commit message. The editor is invoked so you can\n> +\tmake subsequent changes. If you make no changes, the message\n> +\tis considered empty and the commit is aborted. If a message\n> +\tis specified using the `-m` or `-F` options, this option has\n> +\tno effect. This overrides the `commit.template`\n> +\tconfiguration variable.\n\nFirst, think of template not as the \"initial version\" but as \"a form that\nneeds to be filled\", and imagine that you are explaining to a beginner how\nto create a commit.\n\nThe word you would choose to use would be very different if you rephrase\nthe above after doing that mental exercise, and I suspect that it would\nbecome much easier to read.\n\nFor example:\n\n    - subsequent changes --> fill in the form\n    - If ... considerede empty and --> If you did not fill the form\n"},{"id":"188120","messageId":"4F75236C.4050703@gmail.com","threadId":"30098","inReplyTo":"7vboneq1vs.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] git-commit.txt: clarify -t requires editing message","fromName":"Adam Monsen","fromEmail":"haircut@gmail.com","sentAt":"2012-03-30T03:07:24Z","receivedAt":"2012-03-30T03:07:24Z","isPatch":true,"sender":{"key":"haircut@gmail.com","avatar":"https://avatars.githubusercontent.com/u/50639?v=4"},"body":"Junio C. Hamano wrote:\n> First, think of template not as the \"initial version\" but as \"a form\n> that needs to be filled\"\n\nAh, that clarifies for me what the authors had in mind when\nimplementing this feature.\n\nI was hoping to use this feature to pre-populate the commit message\nin my editor and have the option to edit it or leave it as-is. This\nis what the word \"template\" means for me. For example: if I open a\n\"template\" in LibreOffice, I can make changes or not, and\nLibreOffice still lets me print or save at any point.\n\nNow that I know it's not that at all, but rather something more like\na mandatory fillable form, I'll find another way to achieve my need.\nSince git really wants me to enter *something* for a commit message,\nI understand why git \"templates\" work differently than LibreOffice\n\"templates\".\n\nIt's getting a little wordy, but here's an attempt to work in the\n\"form\" concept:\n\n~~~\nUse the contents of the given file as the initial version of the\ncommit message. Think of this initial version as a mandatory\nfillable form. The editor is invoked so you can fill in the form. If\nyou do not fill in the form (if you make no changes), the message is\nconsidered empty and the commit is aborted. If a message is\nspecified using the `-m` or `-F` options, this option has no effect.\nThis overrides the `commit.template` configuration variable.\n~~~\n\nThoughts?\n\n"},{"id":"188122","messageId":"7vr4waoics.fsf@alter.siamese.dyndns.org","threadId":"30098","inReplyTo":"4F75236C.4050703@gmail.com","subject":"Re: [PATCH v2] git-commit.txt: clarify -t requires editing message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-30T03:52:51Z","receivedAt":"2012-03-30T03:52:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Monsen <haircut@gmail.com> writes:\n\n> ~~~\n> Use the contents of the given file as the initial version of the\n> commit message. Think of this initial version as a mandatory\n> fillable form. The editor is invoked so you can fill in the form. If\n> you do not fill in the form (if you make no changes), the message is\n> considered empty and the commit is aborted. If a message is\n> specified using the `-m` or `-F` options, this option has no effect.\n> This overrides the `commit.template` configuration variable.\n> ~~~\n>\n> Thoughts?\n\nYou still say \"the message is considered empty and\" but I think it\nprobably reads better without it.  Strictly speaking, it is not a\n\"mandatory fillable form\", but whatever text you put in the template is\nadvisory to the users.  For example, if your project wants its contributor\nto always refer to a bug id in its issue tracker, it may want to give a\ncustomized \"template\", instead of the plain \"template\" we give to the\nusers that begins with:\n\n\t~~~~~~~~\n\n        # Please enter the commit message for your changes. Lines starting\n        # with '#' will be ignored, and an empty message aborts the commit.\n\t~~~~~~~~\n\nto guide them what to write in the log and how to explain your change,\ne.g. something like:\n\n\t~~~~~~~~\n\t<<one line summary your change here>>\n\n\t# explain the problem your change tries to solve in the first\n        # paragraph\n\n\t# describe the approach your solution takes to solve it in the\n        # second and subsequent paragraphs\n\n\t# Please write issue tracker ID at the end, if available\n\tFrotz-Bug-Id: XXXXXX\n\n        # Always sign-off your commit\n        Signed-off-by: XXXXXX\n\t~~~~~~~~\n"},{"id":"188124","messageId":"4F753C3F.7010805@gmail.com","threadId":"30098","inReplyTo":"7vr4waoics.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] git-commit.txt: clarify -t requires editing message","fromName":"Adam Monsen","fromEmail":"haircut@gmail.com","sentAt":"2012-03-30T04:53:19Z","receivedAt":"2012-03-30T04:53:19Z","isPatch":true,"sender":{"key":"haircut@gmail.com","avatar":"https://avatars.githubusercontent.com/u/50639?v=4"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nJunio C Hamano wrote:\n> You still say \"the message is considered empty and\" but I think it\n>  probably reads better without it.\n\nDo you like the patch without those words?\n\n> Strictly speaking, it is not a \"mandatory fillable form\", but \n> whatever text you put in the template is advisory to the users.\n\nOk, right on. I understand the template feature now since you've\npatiently explained it to me (thank you!). I still want to plainly\nconvey that even if my template is the following:\n\n\t~~~~\n\tzip module: continue to expand transformer\n\t\n\tThis WIP will eventually provide expanded\n\ttransformer functionality.\n\t~~~~\n\nI *cannot* just save and quit my editor (unless I supply\n- --allow-empty-message). That's the behavior I find confusing: git\ntelling me a non-empty commit message is an empty commit message. If I\nsave that text above (zip module... etc) in FILE and do `git commit -t\nFILE`, save and quit my editor, git says \"Aborting commit due to empty\ncommit message.\" Lies! A more precise message would be \"Aborting\ncommit due to unmodified commit message template.\"\n\nBased on the current documentation I misunderstood that -t could be\nused to review a boilerplate commit message and save it verbatim.\n\n...AHA! I just figured out a way to do exactly that:\n\n\tgit commit --edit --file=FILE\n\naka\n\n\tgit commit -eF FILE\n\nYay! No idea how I missed that before.\n\nAnyway, it still seems like the documentation for \"git commit -t\"\ncould use improvement. I actually wouldn't mind seeing a short example\ntemplate like the one you provided, maybe in the EXAMPLES or\nDISCUSSION section.\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.11 (GNU/Linux)\n\niQEcBAEBAgAGBQJPdTw/AAoJEJtdmT+DbynAte4IALRx50yW5bEfzXskvSDewPuL\nSgaU4CqUHRm8sWXHeFbd4I2rG4dEJuqYqzKKbfay3EMwEbIkThiwoC2pJ9xJoFpe\n8O95GVp3ikYvsY3mn87ebiwA9FBhnTy1Fz+MREfuzETpJbdtJSHhbRXMxfJ9ZabU\nFOPE/qeZDvQJA9b9QFY3QS/BcxsGHXhW9xCULZlAprDggMcchhHDEbqJCh/1wObw\ncQvoONiqZSkXA17K3gxfs7NgafUVFIg3+N9vcq90eZXbT/s1MM+1zxj5ezTh9jbV\nsOkzepfE5+NBK3PnewMDxDxhF0LD5lzHCwnfkTl1Om3okSE0nxVyRZKabuzc99s=\n=NUN8\n-----END PGP SIGNATURE-----\n"},{"id":"188125","messageId":"7vehsaoev5.fsf@alter.siamese.dyndns.org","threadId":"30098","inReplyTo":"4F753C3F.7010805@gmail.com","subject":"Re: [PATCH v2] git-commit.txt: clarify -t requires editing message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-30T05:08:14Z","receivedAt":"2012-03-30T05:08:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Monsen <haircut@gmail.com> writes:\n\n> I *cannot* just save and quit my editor (unless I supply\n> --allow-empty-message). That's the behavior I find confusing...\n\nThe root cause of the confusion is that the entire \"--template\" code piggy\nbacks on the non-templated case, where we would want to error out if the\nuser leaves the editor without explaining the commit. And an appropriate\ndiagnosis message for the \"normal\" case is \"you gave me an empty message\",\nbut \"--template\" code did not bother updating that to suit what it tries\nto do better, e.g. \"you did not edit the template I gave you\".\n\nThe check to see if the message the user left matches that came from the\ntemplate was tacked into a wrong function message_is_empty(); it should be\nmade into its own helper function and called from the same caller where\nit calls message_is_empty() only when template_file is not NULL.  Also its\nhonoring \"--allow-empty\" needs to be reconsidered.\n\nIn other words, I think that is something that needs fixing the broken\ncode to behave less confusingly, not documenting its wrong behaviour.\n"},{"id":"188128","messageId":"4F7547EA.9050609@gmail.com","threadId":"30098","inReplyTo":"7vehsaoev5.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] git-commit.txt: clarify -t requires editing message","fromName":"Adam Monsen","fromEmail":"haircut@gmail.com","sentAt":"2012-03-30T05:43:06Z","receivedAt":"2012-03-30T05:43:06Z","isPatch":true,"sender":{"key":"haircut@gmail.com","avatar":"https://avatars.githubusercontent.com/u/50639?v=4"},"body":"Junio C Hamano wrote:\n> I think that is something that needs fixing the broken code to behave\n> less confusingly, not documenting its wrong behaviour.\n\nExcellent! I concur.\n\nI wish I wanted to do this enough to make time to work on it. Ivan, how\nare your C chops? :)\n\n"},{"id":"188182","messageId":"7vaa2ylzrm.fsf@alter.siamese.dyndns.org","threadId":"30098","inReplyTo":"4F7547EA.9050609@gmail.com","subject":"Re: [PATCH v2] git-commit.txt: clarify -t requires editing message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-30T18:17:17Z","receivedAt":"2012-03-30T18:17:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Monsen <haircut@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>> I think that is something that needs fixing the broken code to behave\n>> less confusingly, not documenting its wrong behaviour.\n>\n> Excellent! I concur.\n>\n> I wish I wanted to do this enough to make time to work on it. Ivan, how\n> are your C chops? :)\n\nDon't worry.  While looking around the vicinity of the codepath, I noticed\na few more bugs there, so I'll post something today.\n"},{"id":"188187","messageId":"1333136719-12657-1-git-send-email-gitster@pobox.com","threadId":"30098","inReplyTo":"7vaa2ylzrm.fsf@alter.siamese.dyndns.org","subject":"[PATCH 0/3] \"commit --template\" fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-30T19:45:16Z","receivedAt":"2012-03-30T19:45:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When the user exited editor without editing the commit log template given\nby \"git commit -t <template>\", the commit was aborted (correct) with an\nerror message that said \"due to empty commit message\" (incorrect).  The\ngoal of this series is to fix this, which is the third patch.\n\nWhile looking at this, I found another bug that the contents of the\ntemplate file is still used for error checking even when it is ignored\nwhen the editor is populated for the user to edit.  The second patch\naddresses this.\n\nJunio C Hamano (3):\n  t7501: test the right kind of breakage\n  commit: do not trigger bogus \"has templated message edited\" check\n  commit: rephrase the error when user did not touch templated log message\n\n builtin/commit.c  |   62 +++++++++++++++++++++++++++++++++++++----------------\n t/t7501-commit.sh |   14 ++++++++++++\n 2 files changed, 57 insertions(+), 19 deletions(-)\n\n-- \n1.7.10.rc3.55.g06e99\n"},{"id":"188189","messageId":"1333136719-12657-2-git-send-email-gitster@pobox.com","threadId":"30098","inReplyTo":"1333136719-12657-1-git-send-email-gitster@pobox.com","subject":"[PATCH 1/3] t7501: test the right kind of breakage","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-30T19:45:17Z","receivedAt":"2012-03-30T19:45:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"These tests try to run \"git commit\" with various \"forbidden\" combinations\nof options and expect the command to fail, but they do so without having\nany change added to the index.  We wouldn't be able to catch breakages\nthat would allow these combinations by mistake with them because the\ncommand will fail with \"nothing to commit\" anyway.\n\nMake sure we have something added to the index before running the command.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t7501-commit.sh |    2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/t7501-commit.sh b/t/t7501-commit.sh\nindex 8bb3833..45446b1 100755\n--- a/t/t7501-commit.sh\n+++ b/t/t7501-commit.sh\n@@ -30,10 +30,12 @@ test_expect_success 'setup: initial commit' '\n '\n \n test_expect_success '-m and -F do not mix' '\n+\tgit checkout HEAD file && echo >>file && git add file &&\n \ttest_must_fail git commit -m foo -m bar -F file\n '\n \n test_expect_success '-m and -C do not mix' '\n+\tgit checkout HEAD file && echo >>file && git add file &&\n \ttest_must_fail git commit -C HEAD -m illegal\n '\n \n-- \n1.7.10.rc3.55.g06e99\n"},{"id":"188190","messageId":"1333136719-12657-3-git-send-email-gitster@pobox.com","threadId":"30098","inReplyTo":"1333136719-12657-1-git-send-email-gitster@pobox.com","subject":"[PATCH 2/3] commit: do not trigger bogus \"has templated message edited\" check","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-30T19:45:18Z","receivedAt":"2012-03-30T19:45:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When \"-t template\" and \"-F msg\" options are both given (or worse yet,\nthere is \"commit.template\" configuration but a message is given in some\nother way), the documentation says that template is ignored.  However,\nthe \"has the user edited the message?\" check still used the contents of\nthe template file as the basis of the emptyness check.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/commit.c  |    2 ++\n t/t7501-commit.sh |    6 ++++++\n 2 files changed, 8 insertions(+)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex eba1377..7141766 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1049,6 +1049,8 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \t\tdie(_(\"Only one of -c/-C/-F/--fixup can be used.\"));\n \tif (message.len && f > 0)\n \t\tdie((_(\"Option -m cannot be combined with -c/-C/-F/--fixup.\")));\n+\tif (f || message.len)\n+\t\ttemplate_file = NULL;\n \tif (edit_message)\n \t\tuse_message = edit_message;\n \tif (amend && !use_message && !fixup_message)\ndiff --git a/t/t7501-commit.sh b/t/t7501-commit.sh\nindex 45446b1..e59cc4e 100755\n--- a/t/t7501-commit.sh\n+++ b/t/t7501-commit.sh\n@@ -81,7 +81,13 @@ test_expect_success 'empty commit message' '\n \ttest_must_fail git commit -F msg -a\n '\n \n+test_expect_success 'template \"emptyness\" check does not kick in with -F' '\n+\tgit checkout HEAD file && echo >>file && git add file &&\n+\tgit commit -t file -F file\n+'\n+\n test_expect_success 'setup: commit message from file' '\n+\tgit checkout HEAD file && echo >>file && git add file &&\n \techo this is the commit message, coming from a file >msg &&\n \tgit commit -F msg -a\n '\n-- \n1.7.10.rc3.55.g06e99\n"},{"id":"188188","messageId":"1333136719-12657-4-git-send-email-gitster@pobox.com","threadId":"30098","inReplyTo":"1333136719-12657-1-git-send-email-gitster@pobox.com","subject":"[PATCH 3/3] commit: rephrase the error when user did not touch templated log message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-30T19:45:19Z","receivedAt":"2012-03-30T19:45:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When the user exited editor without editing the commit log template given\nby \"git commit -t <template>\", the commit was aborted (correct) with an\nerror message that said \"due to empty commit message\" (incorrect).\n\nThis was because the original template support was done by piggybacking on\nthe check to detect an empty log message.  Split the codepaths into two\nindependent checks to clarify the error.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/commit.c  |   60 ++++++++++++++++++++++++++++++++++++-----------------\n t/t7501-commit.sh |    6 ++++++\n 2 files changed, 47 insertions(+), 19 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 7141766..847d363 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -899,27 +899,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \treturn 1;\n }\n \n-/*\n- * Find out if the message in the strbuf contains only whitespace and\n- * Signed-off-by lines.\n- */\n-static int message_is_empty(struct strbuf *sb)\n+static int rest_is_empty(struct strbuf *sb, int start)\n {\n-\tstruct strbuf tmpl = STRBUF_INIT;\n+\tint i, eol;\n \tconst char *nl;\n-\tint eol, i, start = 0;\n-\n-\tif (cleanup_mode == CLEANUP_NONE && sb->len)\n-\t\treturn 0;\n-\n-\t/* See if the template is just a prefix of the message. */\n-\tif (template_file && strbuf_read_file(&tmpl, template_file, 0) > 0) {\n-\t\tstripspace(&tmpl, cleanup_mode == CLEANUP_ALL);\n-\t\tif (start + tmpl.len <= sb->len &&\n-\t\t    memcmp(tmpl.buf, sb->buf + start, tmpl.len) == 0)\n-\t\t\tstart += tmpl.len;\n-\t}\n-\tstrbuf_release(&tmpl);\n \n \t/* Check if the rest is just whitespace and Signed-of-by's. */\n \tfor (i = start; i < sb->len; i++) {\n@@ -942,6 +925,40 @@ static int message_is_empty(struct strbuf *sb)\n \treturn 1;\n }\n \n+/*\n+ * Find out if the message in the strbuf contains only whitespace and\n+ * Signed-off-by lines.\n+ */\n+static int message_is_empty(struct strbuf *sb)\n+{\n+\tif (cleanup_mode == CLEANUP_NONE && sb->len)\n+\t\treturn 0;\n+\treturn rest_is_empty(sb, 0);\n+}\n+\n+/*\n+ * See if the user edited the message in the editor or left what\n+ * was in the template intact\n+ */\n+static int template_untouched(struct strbuf *sb)\n+{\n+\tstruct strbuf tmpl = STRBUF_INIT;\n+\tchar *start;\n+\n+\tif (cleanup_mode == CLEANUP_NONE && sb->len)\n+\t\treturn 0;\n+\n+\tif (!template_file || strbuf_read_file(&tmpl, template_file, 0) <= 0)\n+\t\treturn 0;\n+\n+\tstripspace(&tmpl, cleanup_mode == CLEANUP_ALL);\n+\tstart = (char *)skip_prefix(sb->buf, tmpl.buf);\n+\tif (!start)\n+\t\tstart = sb->buf;\n+\tstrbuf_release(&tmpl);\n+\treturn rest_is_empty(sb, start - sb->buf);\n+}\n+\n static const char *find_author_by_nickname(const char *name)\n {\n \tstruct rev_info revs;\n@@ -1490,6 +1507,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \n \tif (cleanup_mode != CLEANUP_NONE)\n \t\tstripspace(&sb, cleanup_mode == CLEANUP_ALL);\n+\tif (template_untouched(&sb) && !allow_empty_message) {\n+\t\trollback_index_files();\n+\t\tfprintf(stderr, _(\"Aborting commit; you did not edit the message.\\n\"));\n+\t\texit(1);\n+\t}\n \tif (message_is_empty(&sb) && !allow_empty_message) {\n \t\trollback_index_files();\n \t\tfprintf(stderr, _(\"Aborting commit due to empty commit message.\\n\"));\ndiff --git a/t/t7501-commit.sh b/t/t7501-commit.sh\nindex e59cc4e..b20ca0e 100755\n--- a/t/t7501-commit.sh\n+++ b/t/t7501-commit.sh\n@@ -86,6 +86,12 @@ test_expect_success 'template \"emptyness\" check does not kick in with -F' '\n \tgit commit -t file -F file\n '\n \n+test_expect_success 'template \"emptyness\" check' '\n+\tgit checkout HEAD file && echo >>file && git add file &&\n+\ttest_must_fail git commit -t file 2>err &&\n+\ttest_i18ngrep \"did not edit\" err\n+'\n+\n test_expect_success 'setup: commit message from file' '\n \tgit checkout HEAD file && echo >>file && git add file &&\n \techo this is the commit message, coming from a file >msg &&\n-- \n1.7.10.rc3.55.g06e99\n"},{"id":"188260","messageId":"4F775ACF.50007@gmail.com","threadId":"30098","inReplyTo":"1333136719-12657-1-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 0/3] \"commit --template\" fixes","fromName":"Adam Monsen","fromEmail":"haircut@gmail.com","sentAt":"2012-03-31T19:28:15Z","receivedAt":"2012-03-31T19:28:15Z","isPatch":true,"sender":{"key":"haircut@gmail.com","avatar":"https://avatars.githubusercontent.com/u/50639?v=4"},"body":"On 03/30/2012 12:45 PM, Junio C Hamano wrote:\n> When the user exited editor without editing the commit log template \n> given by \"git commit -t <template>\", the commit was aborted (correct)\n> with an error message that said \"due to empty commit message\"\n> (incorrect).  The goal of this series is to fix this, which is the\n> third patch.\n\nThis is awesome. thanks!\n\nI really like the new error message specific to the situation when\nthe user does not edit the template (as we discussed).\n\nYour patches apply cleanly to maint b8939b2b3abaa.\n\nI tested the patches and they work as expected. When I use\n`git commit --template FILE` but do not edit the message in my editor,\nI get\n\n\tAborting commit; you did not edit the message.\n\nNice.\n\nOnly thing I'd add is a change to the git-commit(1) manpage.\n\n* I prefer pragmatically explaining what will happen when the user\n  uses --template but does not edit the message because it is more\n  direct and terse (than \"filling in a form\").\n* The below applies cleanly to maint as of today.\n* I don't know the kosher procedure to add this commit to your patch\n  series for further review, so hopefully this works.\n* I'm not sure if the \"Helped-by:\" lines are kosher, I'm happy to\n  remove them if not.\n\nFrom 91a62baa1fe89032e7a3598e5d39241f3eb8f84b Mon Sep 17 00:00:00 2001\nFrom: Adam Monsen <haircut@gmail.com>\nDate: Sat, 31 Mar 2012 12:09:29 -0700\nSubject: [PATCH] git-commit.txt: clarify -t requires editing message\n\nMake it clear that, when using commit --template, the message *must* be\nchanged or the commit will be aborted.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: Ivan Heffner <iheffner@gmail.com>\nSigned-off-by: Adam Monsen <haircut@gmail.com>\n---\nI wrapped the text at 77 characters because that was the longest\nline in the file (according to wc -L).\n\nI used \":set noet nosta ts=8 sw=8 tw=77\" in Vim.\n\n Documentation/git-commit.txt |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 5cc84a1..f584a62 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -132,11 +132,11 @@ OPTIONS\n \n -t <file>::\n --template=<file>::\n-\tUse the contents of the given file as the initial version\n-\tof the commit message. The editor is invoked and you can\n-\tmake subsequent changes. If a message is specified using\n-\tthe `-m` or `-F` options, this option has no effect. This\n-\toverrides the `commit.template` configuration variable.\n+\tUse the contents of the given file as the initial version of the\n+\tcommit message. The editor is invoked so you can make subsequent\n+\tchanges. If you make no changes, the commit is aborted. If a message\n+\tis specified using the `-m` or `-F` options, this option has no\n+\teffect. This overrides the `commit.template` configuration variable.\n \n -s::\n --signoff::\n-- \n1.7.5.4\n\n"},{"id":"188287","messageId":"7vaa2vhyso.fsf@alter.siamese.dyndns.org","threadId":"30098","inReplyTo":"4F775ACF.50007@gmail.com","subject":"Re: [PATCH 0/3] \"commit --template\" fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-01T22:28:39Z","receivedAt":"2012-04-01T22:28:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Monsen <haircut@gmail.com> writes:\n\n> ...\n> * I don't know the kosher procedure to add this commit to your patch\n>   series for further review, so hopefully this works.\n> * I'm not sure if the \"Helped-by:\" lines are kosher, I'm happy to\n>   remove them if not.\n\nOne established way to do this is to have a discussion like the above\n(mostly elided), followed by a \"scissors\" line \"-- >8 --\", and then the\noutput from format-patch with most headers except for \"Subject: \" removed\n(as From: and Date: will be taken from your e-mailed message anyway, and\nthe first \"From <commit object name> <magic constant date>\" is a signal to\nallow automated tools to tell if it is a format-patch output or a random\nmbox file, and is not appropriate if you are sending it over e-mail).\n\n>\n> From 91a62baa1fe89032e7a3598e5d39241f3eb8f84b Mon Sep 17 00:00:00 2001\n> From: Adam Monsen <haircut@gmail.com>\n> Date: Sat, 31 Mar 2012 12:09:29 -0700\n> Subject: [PATCH] git-commit.txt: clarify -t requires editing message\n>\n> Make it clear that, when using commit --template, the message *must* be\n> changed or the commit will be aborted.\n>\n>\n> Helped-by: Junio C Hamano <gitster@pobox.com>\n> Helped-by: Ivan Heffner <iheffner@gmail.com>\n> Signed-off-by: Adam Monsen <haircut@gmail.com>\n> ---\n> I wrapped the text at 77 characters because that was the longest\n> line in the file (according to wc -L).\n>\n> I used \":set noet nosta ts=8 sw=8 tw=77\" in Vim.\n\nWhen rewording or clarifying only a handful of words in the documentation,\nit is often better to avoid reflowing lines in the same patch.  It makes\nit harder to see what you really changed, and what is merely reflowed.\n\nI'll queue it as-is, though.  Thanks.\n\nThis is a tangent, but we might want to rephrase the first sentence\nwithout using the word \"version\"; every time I read this paragraph, the\n\"initial version\" makes me go \"Huh?\" because the word sounds as if it is\ntalking about commits in the context of SCM, which is not the case here.\n\nI know that the description wanted to avoid use of the word \"template\" to\nexplain what the template is, but still...\n\n>  Documentation/git-commit.txt |   10 +++++-----\n>  1 files changed, 5 insertions(+), 5 deletions(-)\n>\n> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\n> index 5cc84a1..f584a62 100644\n> --- a/Documentation/git-commit.txt\n> +++ b/Documentation/git-commit.txt\n> @@ -132,11 +132,11 @@ OPTIONS\n>  \n>  -t <file>::\n>  --template=<file>::\n> -\tUse the contents of the given file as the initial version\n> -\tof the commit message. The editor is invoked and you can\n> -\tmake subsequent changes. If a message is specified using\n> -\tthe `-m` or `-F` options, this option has no effect. This\n> -\toverrides the `commit.template` configuration variable.\n> +\tUse the contents of the given file as the initial version of the\n> +\tcommit message. The editor is invoked so you can make subsequent\n> +\tchanges. If you make no changes, the commit is aborted. If a message\n> +\tis specified using the `-m` or `-F` options, this option has no\n> +\teffect. This overrides the `commit.template` configuration variable.\n>  \n>  -s::\n>  --signoff::\n"},{"id":"188422","messageId":"4F7B2F35.40807@gmail.com","threadId":"30098","inReplyTo":"7vaa2vhyso.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/3] \"commit --template\" fixes","fromName":"Adam Monsen","fromEmail":"haircut@gmail.com","sentAt":"2012-04-03T17:11:17Z","receivedAt":"2012-04-03T17:11:17Z","isPatch":true,"sender":{"key":"haircut@gmail.com","avatar":"https://avatars.githubusercontent.com/u/50639?v=4"},"body":"On 04/01/2012 03:28 PM, Junio C Hamano wrote:\n> One established way to do this is to have a discussion like the above\n> (mostly elided), followed by a \"scissors\" line...\n\nI can do that. Thanks!\n\n> When rewording or clarifying only a handful of words in the documentation,\n> it is often better to avoid reflowing lines in the same patch.\n\nI thought of that, but it made the right margin jagged. :)\nMy new suggestion (below) isolates the changes a bit better.\n\n> This is a tangent, but we might want to rephrase the first sentence\n> without using the word \"version\"; every time I read this paragraph, the\n> \"initial version\" makes me go \"Huh?\" because the word sounds as if it is\n> talking about commits in the context of SCM, which is not the case here.\n\nYeah, that bugs me too.\n\nHow about this? I'm a little bummed it doesn't include why\ncommit --template exists at all, but it reads well: terse and to the\npoint like (IMHO) a manpage should.\n\n-- >8 --\nSubject: [PATCH v4] git-commit.txt: clarify -t requires editing message\n\nMake it clear that, when using commit --template, the message *must* be\nchanged or the commit will be aborted.\n\nAlso, remove the words \"initial version\" to avoid confusion. Commit\nmessages are not versioned independently of commits.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: Ivan Heffner <iheffner@gmail.com>\nSigned-off-by: Adam Monsen <haircut@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\nReplaces b0ad5e27803cd of jc/commit-unedited-template. I'm assuming that's ok\nsince the branch isn't merged into maint or master.\n\n Documentation/git-commit.txt |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 5cc84a1..bd82431 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -132,9 +132,9 @@ OPTIONS\n \n -t <file>::\n --template=<file>::\n-\tUse the contents of the given file as the initial version\n-\tof the commit message. The editor is invoked and you can\n-\tmake subsequent changes. If a message is specified using\n+\tUse the contents of the given file as the commit message. The\n+\teditor is invoked so you can make subsequent changes. If you make no\n+\tchanges, the commit is aborted. If a message is specified using\n \tthe `-m` or `-F` options, this option has no effect. This\n \toverrides the `commit.template` configuration variable.\n \n-- \n1.7.5.4\n"},{"id":"188442","messageId":"7v1uo4cwg7.fsf@alter.siamese.dyndns.org","threadId":"30098","inReplyTo":"4F7B2F35.40807@gmail.com","subject":"Re: [PATCH 0/3] \"commit --template\" fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-03T21:55:04Z","receivedAt":"2012-04-03T21:55:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adam Monsen <haircut@gmail.com> writes:\n\n> How about this? I'm a little bummed it doesn't include why commit\n> --template exists at all, but it reads well: terse and to the point like\n> (IMHO) a manpage should.\n\nPerhaps we should explain why somebody might want to use --template\ninstead of -F; personally, I do not think --template command line option\nwould not make much sense unless it is used as a part of a script that\nenforces external constraints in a larger workflow, even though such a\nproject could instead require the participants to set commit.template to\none supplied by the project.  As an enforcement mechanism, use of such\nstricter \"commit wrapper\" and commit.template configuration cannot be\nmechanical and absolute either way, as Git is distributed and whatever\nhappens in the participant's repository is purely up to the participant.\n\n>  -t <file>::\n>  --template=<file>::\n> +\tUse the contents of the given file as the commit message. The\n> +\teditor is invoked so you can make subsequent changes. If you make no\n> +\tchanges, the commit is aborted. If a message is specified using\n>  \tthe `-m` or `-F` options, this option has no effect. This\n>  \toverrides the `commit.template` configuration variable.\n\nWhen editing the commit message, start the editor with the contents in the\ngiven file.  The `commit.template` configuration variable is often used to\ngive this option implicitly to the command.  This mechanism can be used by\nprojects that want to guide participants with some hints on what to write\nin the message in what order.  If the user exits the editor without editing\nthe message, the commit is aborted.  This has no effect when a message is\ngiven by other means, e.g. with the `-m` or `-F` options.\n\nHmm?\n"},{"id":"188564","messageId":"4F7DAC61.3000104@gmail.com","threadId":"30098","inReplyTo":"7v1uo4cwg7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/3] \"commit --template\" fixes","fromName":"Adam Monsen","fromEmail":"haircut@gmail.com","sentAt":"2012-04-05T14:29:53Z","receivedAt":"2012-04-05T14:29:53Z","isPatch":true,"sender":{"key":"haircut@gmail.com","avatar":"https://avatars.githubusercontent.com/u/50639?v=4"},"body":"On 04/03/2012 02:55 PM, Junio C Hamano wrote:\n> When editing the commit message, start the editor with the contents in the\n> given file.  The `commit.template` configuration variable is often used to\n> give this option implicitly to the command.  This mechanism can be used by\n> projects that want to guide participants with some hints on what to write\n> in the message in what order.  If the user exits the editor without editing\n> the message, the commit is aborted.  This has no effect when a message is\n> given by other means, e.g. with the `-m` or `-F` options.\n\nI like it!\n\n"}]}