{"thread":{"id":"22852","subject":"Commit log message typos and spell mistakes","startedAt":"2010-02-28T00:01:43Z","lastAt":"2010-03-03T14:45:18Z","messageCount":7,"participants":["Steven Drake","Jeff King","Teemu Likonen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"135863","messageId":"alpine.LNX.2.00.1002281258340.15334@vqena.qenxr.bet.am","threadId":"22852","inReplyTo":null,"subject":"Commit log message typos and spell mistakes","fromName":"Steven Drake","fromEmail":"sdrake@xnet.co.nz","sentAt":"2010-02-28T00:01:43Z","receivedAt":"2010-02-28T00:01:43Z","isPatch":false,"sender":{"key":"sdrake@xnet.co.nz","avatar":null},"body":"On Fri, 26 Feb 2010, Alex Riesen wrote:\n> On Fri, Feb 26, 2010 at 05:00, Steven Drake <sdrake@xnet.co.nz> wrote:\n> > It is not a good Idea to give a config_error for _any_ keyword without a\n> > value as it means that\n> >\n> >        [section]\n> >                keyword\n> >\n> > sytle can not be using for setting bool type keyword.\n> \n> Typo: sytle (style?)\n\nYes dammit, time to teach git to do spell checking!\n\n-- \nSteven\n  1: Linux - will work for fish.\n  2: The Linux penguin - looks stuffed to the brim with herring.\n  ( make your own conclusions )"},{"id":"299167","messageId":"7e21d6cd64aa088763c3ff11d6cbe78899ae7f10.1267314986.git.sdrake@xnet.co.nz","threadId":"22852","inReplyTo":"alpine.LNX.2.00.1002281258340.15334@vqena.qenxr.bet.am","subject":"[PATCH 1/1] Add commit log message spell checking feature.","fromName":"Steven Drake","fromEmail":"sdrake@xnet.co.nz","sentAt":"2010-02-28T00:03:00Z","receivedAt":"2010-02-28T00:03:00Z","isPatch":true,"sender":{"key":"sdrake@xnet.co.nz","avatar":null},"body":"Add 'git commit --spell' to run a spell checker on commit log message.\nThe `commit.spell` configuration variable can be used to enable the spell\nchecker by default and can be turned off by '--no-spell'.\n\nThe spell checker shell command to run is specified by the\n`commit.spellcommand` configuration variable and defaults to `ispell`.\n\nBecause it is assumed that the spell checker is an interactive command spell\nchecking is only done if stdio is a terminal.\n\nSigned-off-by: Steven Drake <sdrake@xnet.co.nz>\n---\nThe above commit log message was spell check using this feature.\n\n Documentation/config.txt     |    9 +++++++++\n Documentation/git-commit.txt |    8 ++++++++\n builtin/commit.c             |   33 ++++++++++++++++++++++++++++++++-\n 3 files changed, 49 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 793c9a8..f977a45 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -737,6 +737,15 @@ color.ui::\n \tterminal. When more specific variables of color.* are set, they always\n \ttake precedence over this setting. Defaults to false.\n \n+commit.spell::\n+\tA boolean to enable/disable running of the spell checker on commit\n+\tlog message. Defaults to false.\n+\n+commit.spellcommand::\n+\tShell command to run as the spell checker. First argument given to\n+\tthe command is the name of the file containing the commit log message.\n+\tDefaults to `ispell`.  See 'ispell(1)'.\n+\n commit.status::\n \tA boolean to enable/disable inclusion of status information in the\n \tcommit message template when using an editor to prepare the commit\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex 64fb458..d68106f 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -120,6 +120,14 @@ OPTIONS\n \tAdd Signed-off-by line by the committer at the end of the commit\n \tlog message.\n \n+--spell::\n+\tRun the spell checker on commit log message. This overrides the\n+\t`commit.spell` configuration variable.\n+\n+--no-spell::\n+\tDo not run the spell checker on commit log message. This overrides the\n+\t`commit.spell` configuration variable.\n+\n -n::\n --no-verify::\n \tThis option bypasses the pre-commit and commit-msg hooks.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 8dd104e..272faa7 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -66,7 +66,8 @@ static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n static int all, edit_flag, also, interactive, only, amend, signoff;\n static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;\n-static int no_post_rewrite;\n+static int no_post_rewrite, spell_check;\n+static const char *spell_command = (const char*)\"ispell\";\n static char *untracked_files_arg, *force_date;\n /*\n  * The default commit message cleanup mode will remove the lines\n@@ -93,6 +94,11 @@ static enum {\n \tSTATUS_FORMAT_PORCELAIN,\n } status_format = STATUS_FORMAT_LONG;\n \n+static inline int have_terminal(void)\n+{\n+\treturn (isatty(0) && isatty(1) && isatty(2));\n+}\n+\n static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n {\n \tstruct strbuf *buf = opt->value;\n@@ -118,6 +124,7 @@ static struct option builtin_commit_options[] = {\n \tOPT_STRING('C', \"reuse-message\", &use_message, \"COMMIT\", \"reuse message from specified commit\"),\n \tOPT_BOOLEAN(0, \"reset-author\", &renew_authorship, \"the commit is authored by me now (used with -C-c/--amend)\"),\n \tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n+\tOPT_BOOLEAN(0, \"spell\", &spell_check, \"run spell checker on commit message\"),\n \tOPT_FILENAME('t', \"template\", &template_file, \"use specified template file\"),\n \tOPT_BOOLEAN('e', \"edit\", &edit_flag, \"force edit of commit\"),\n \tOPT_STRING(0, \"cleanup\", &cleanup_arg, \"default\", \"how to strip spaces and #comments from message\"),\n@@ -525,6 +532,21 @@ static int ends_rfc2822_footer(struct strbuf *sb)\n \treturn 1;\n }\n \n+static int spell_checker(const char *commit_editmsg)\n+{\n+\tconst char *terminal = getenv(\"TERM\");\n+\tint terminal_is_dumb = !terminal || !strcmp(terminal, \"dumb\");\n+\n+\tif (terminal_is_dumb || !have_terminal()) {\n+\t\terror(\"No Terminal, can not run spell checker\");\n+\t\treturn 0;\n+\t}\n+\n+\tconst char *args[] = { spell_command, commit_editmsg, NULL };\n+\n+\treturn run_command_v_opt(args, RUN_USING_SHELL);\n+}\n+\n static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t     struct wt_status *s)\n {\n@@ -726,6 +748,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t}\n \t}\n \n+\tif (spell_check && spell_checker(git_path(commit_editmsg)))\n+\t\treturn 0;\n+\n \tif (!no_verify &&\n \t    run_hook(index_file, \"commit-msg\", git_path(commit_editmsg), NULL)) {\n \t\treturn 0;\n@@ -1154,6 +1179,12 @@ static int git_commit_config(const char *k, const char *v, void *cb)\n \n \tif (!strcmp(k, \"commit.template\"))\n \t\treturn git_config_pathname(&template_file, k, v);\n+\tif (!strcmp(k, \"commit.spell\")) {\n+\t\tspell_check = git_config_bool(k, v);\n+\t\treturn 0;\n+\t}\n+\tif (!strcmp(k, \"commit.spellcommand\"))\n+\t\treturn git_config_string(&spell_command, k, v);\n \tif (!strcmp(k, \"commit.status\")) {\n \t\tinclude_status = git_config_bool(k, v);\n \t\treturn 0;\n-- \n1.7.0.323.g7e21d\n\n"},{"id":"135881","messageId":"20100228163339.GA9399@coredump.intra.peff.net","threadId":"22852","inReplyTo":"7e21d6cd64aa088763c3ff11d6cbe78899ae7f10.1267314986.git.sdrake@xnet.co.nz","subject":"Re: [PATCH 1/1] Add commit log message spell checking feature.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-02-28T16:33:39Z","receivedAt":"2010-02-28T16:33:39Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Feb 28, 2010 at 01:03:00PM +1300, Steven Drake wrote:\n\n> Add 'git commit --spell' to run a spell checker on commit log message.\n> The `commit.spell` configuration variable can be used to enable the spell\n> checker by default and can be turned off by '--no-spell'.\n\nIsn't this exactly the sort of thing the commit-msg hook is for? Though\npersonally I would probably just invoke interactive spell-checking from\nthe editor.\n\n-Peff\n"},{"id":"136061","messageId":"alpine.LNX.2.00.1003031947180.19842@vqena.qenxr.bet.am","threadId":"22852","inReplyTo":"20100228163339.GA9399@coredump.intra.peff.net","subject":"Re: [PATCH 1/1] Add commit log message spell checking feature.","fromName":"Steven Drake","fromEmail":"sdrake@xnet.co.nz","sentAt":"2010-03-03T06:50:34Z","receivedAt":"2010-03-03T06:50:34Z","isPatch":true,"sender":{"key":"sdrake@xnet.co.nz","avatar":null},"body":"On Sun, 28 Feb 2010, Jeff King wrote:\n> On Sun, Feb 28, 2010 at 01:03:00PM +1300, Steven Drake wrote:\n> \n> > Add 'git commit --spell' to run a spell checker on commit log message.\n> > The `commit.spell` configuration variable can be used to enable the spell\n> > checker by default and can be turned off by '--no-spell'.\n> \n> Isn't this exactly the sort of thing the commit-msg hook is for?\n\nAccept then there would be no way of having '--spell'/'--no-spell' (Yet!).\n\n> Though personally I would probably just invoke interactive spell-checking\n> from the editor.\n\nI would probably forget to.\n\n-- \nSteven\nI'm such a prick!  --- The Bastard Operator from Hell\n"},{"id":"136062","messageId":"alpine.LNX.2.00.1003032018330.21953@vqena.qenxr.bet.am","threadId":"22852","inReplyTo":"20100228163339.GA9399@coredump.intra.peff.net","subject":"Re: [PATCH 1/1] Add commit log message spell checking feature.","fromName":"Steven Drake","fromEmail":"sdrake@xnet.co.nz","sentAt":"2010-03-03T07:21:49Z","receivedAt":"2010-03-03T07:21:49Z","isPatch":true,"sender":{"key":"sdrake@xnet.co.nz","avatar":null},"body":"On Sun, 28 Feb 2010, Jeff King wrote:\n> On Sun, Feb 28, 2010 at 01:03:00PM +1300, Steven Drake wrote:\n> \n> > Add 'git commit --spell' to run a spell checker on commit log message.\n> > The `commit.spell` configuration variable can be used to enable the spell\n> > checker by default and can be turned off by '--no-spell'.\n> \n> Isn't this exactly the sort of thing the commit-msg hook is for?\n\nPlus as I have just found out all hooks are run with stdin as '/dev/null' so\nthere is no way of running an interactive command like 'ispell' from a hook!\n\n-- \nSteven\n  1: Linux - will work for fish.\n  2: The Linux penguin - looks stuffed to the brim with herring.\n  ( make your own conclusions )\n"},{"id":"136063","messageId":"87aaupj1q3.fsf@mithlond.arda","threadId":"22852","inReplyTo":"20100228163339.GA9399@coredump.intra.peff.net","subject":"Re: [PATCH 1/1] Add commit log message spell checking feature.","fromName":"Teemu Likonen","fromEmail":"tlikonen@iki.fi","sentAt":"2010-03-03T07:36:36Z","receivedAt":"2010-03-03T07:36:36Z","isPatch":true,"sender":{"key":"tlikonen@iki.fi","avatar":null},"body":"* 2010-02-28 11:33 (-0500), Jeff King wrote:\n\n> On Sun, Feb 28, 2010 at 01:03:00PM +1300, Steven Drake wrote:\n>> Add 'git commit --spell' to run a spell checker on commit log\n>> message. The `commit.spell` configuration variable can be used to\n>> enable the spell checker by default and can be turned off by\n>> '--no-spell'.\n>\n> Isn't this exactly the sort of thing the commit-msg hook is for?\n> Though personally I would probably just invoke interactive\n> spell-checking from the editor.\n\nI agree that it's a job for user's text editor.\n"},{"id":"136079","messageId":"20100303144517.GA21385@coredump.intra.peff.net","threadId":"22852","inReplyTo":"alpine.LNX.2.00.1003032018330.21953@vqena.qenxr.bet.am","subject":"Re: [PATCH 1/1] Add commit log message spell checking feature.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-03-03T14:45:18Z","receivedAt":"2010-03-03T14:45:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 03, 2010 at 07:50:34PM +1300, Steven Drake wrote:\n\n> On Sun, 28 Feb 2010, Jeff King wrote:\n> > On Sun, Feb 28, 2010 at 01:03:00PM +1300, Steven Drake wrote:\n> > \n> > > Add 'git commit --spell' to run a spell checker on commit log message.\n> > > The `commit.spell` configuration variable can be used to enable the spell\n> > > checker by default and can be turned off by '--no-spell'.\n> > \n> > Isn't this exactly the sort of thing the commit-msg hook is for?\n> \n> Accept then there would be no way of having '--spell'/'--no-spell' (Yet!).\n\nYou would have to spell it:\n\n  NO_SPELL=1 git commit\n\nwhich admittedly isn't as nice. But I'm not sure why you would want\n--no-spell. I guess for rebases and such where you aren't writing the\nmessage directly? But in that case, shouldn't it be passing --no-verify\nalready (and if we go with your patch, should --no-verify perhaps imply\n--no-spell)?\n\n> Plus as I have just found out all hooks are run with stdin as '/dev/null' so\n> there is no way of running an interactive command like 'ispell' from a hook!\n\nYes, you have to do \"ispell </dev/tty\". Though both that and your\noriginal suffer from somebody running \"git gui\" or similar in a terminal\nthat the user is no longer looking at. I see you check for isatty(), but\nI don't know if that is enough for git gui (or any of the other\ngraphical commit helpers).\n\n> > Though personally I would probably just invoke interactive spell-checking\n> > from the editor.\n> \n> I would probably forget to.\n\nSure, but that is a problem with --spell, too. And you have already\nsolved it here, with commit.spell configuration. So why does that\ntechnique not apply to configuring your editor?\n\nI'm not 100% against your patch. I'm just concerned that it is adding\ncode and complexity for a feature that nobody will use, because\neverybody else is already doing the same thing through their editor,\nwhich is cleaner (e.g., we don't have to worry about handling --no-spell\nfor scripts).\n\n-Peff\n"}]}