{"thread":{"id":"27954","subject":"[PATCH] help_unknown_command: disable auto correction","startedAt":"2011-07-29T15:20:15Z","lastAt":"2011-07-29T15:20:15Z","messageCount":1,"participants":["Theo Niessink"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"172346","messageId":"77D4710D485241B18B21CCA8A543700B@martinic.local","threadId":"27954","inReplyTo":null,"subject":"[PATCH] help_unknown_command: disable auto correction","fromName":"Theo Niessink","fromEmail":"theo@taletn.com","sentAt":"2011-07-29T15:20:15Z","receivedAt":"2011-07-29T15:20:15Z","isPatch":true,"sender":{"key":"theo@taletn.com","avatar":"https://avatars.githubusercontent.com/u/5729397?v=4"},"body":"Hi,\n\nThis is a very minor nitpick, but since it bothers me I thought I'd patch it\nanyway. If it doesn't bother anyone else, then please ignore this patch.\n\nI am a fast but rather inaccurate typer, so now and then I mistype a Git\ncommand. The first time this happens I have to wait up to 15 seconds before\nGit returns with an error. It takes my brain only 0.15 seconds to see the\ntypo, but I still have the wait the remaining 14.45 seconds before I can\nretry.\n\nI have patched help_unknown_command(), so you can disable auto correction\nwith help.autocorrect == -2.\n\nBeware that this is not 100% backward compatible, because before this patch\n_any_ negative value (including -2) would set the auto correction delay to\nzero.\n\n- Theo\n\n-- >8 --\nSubject: [PATCH] help_unknown_command: disable auto correction\n\nAuto correction can be rather slow (because it searches the path), so\ndisable it with \"git config help.autocorrect -2\".\n\nSigned-off-by: Theo Niessink <theo@taletn.com>\n---\n Documentation/config.txt |    5 +++--\n help.c                   |    8 ++++++++\n 2 files changed, 11 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 0658ffb..452e3a8 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1188,10 +1188,11 @@ help.autocorrect::\n \tAutomatically correct and execute mistyped commands after\n \twaiting for the given number of deciseconds (0.1 sec). If more\n \tthan one command can be deduced from the entered text, nothing\n-\twill be executed.  If the value of this option is negative,\n+\twill be executed.  If the value of this option is -1,\n \tthe corrected command will be executed immediately. If the\n \tvalue is 0 - the command will be just shown but not executed.\n-\tThis is the default.\n+\tThis is the default. If the value is -2, auto correction is disabled\n+\taltogether.\n \n http.proxy::\n \tOverride the HTTP proxy, normally configured using the 'http_proxy'\ndiff --git a/help.c b/help.c\nindex cbbe966..31a6d54 100644\n--- a/help.c\n+++ b/help.c\n@@ -320,6 +320,13 @@ const char *help_unknown_cmd(const char *cmd)\n \n \tgit_config(git_unknown_cmd_config, NULL);\n \n+\tif (autocorrect == -2)\n+\t{\n+\t\t/* No similarity */\n+\t\tbest_similarity = SIMILARITY_FLOOR;\n+\t\tgoto skip_autocorrect;\n+\t}\n+\n \tload_command_list(\"git-\", &main_cmds, &other_cmds);\n \n \tadd_cmd_list(&main_cmds, &aliases);\n@@ -396,6 +403,7 @@ const char *help_unknown_cmd(const char *cmd)\n \t\treturn assumed;\n \t}\n \n+skip_autocorrect:\n \tfprintf(stderr, \"git: '%s' is not a git command. See 'git --help'.\\n\", cmd);\n \n \tif (SIMILAR_ENOUGH(best_similarity)) {\n-- \n1.7.6.msysgit.0\n"}]}