[PATCH] Wait help.autocorrect deciseconds before running corrected command
- From
Alex Riesen <raa.lkml@gmail.com>
- Date
- Jul 23, 2008, 16:41 UTC
- Message-ID
- <20080723164109.GA5283@blimp.local>
- In-Reply-To
- <7vsku1jz4u.fsf@gitster.siamese.dyndns.org>
Suggested by Junio, so he has a chance to hit Ctrl-C. --- Junio C Hamano, Wed, Jul 23, 2008 01:08:17 +0200:
> > Please make autocorrect not a binary but optionally the number of > deciseconds before it continues, so that I have a chance to hit ^C ;-)
on top of the last patch.
Documentation/config.txt | 9 +++++++++ help.c | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt index e784805..5bf1d0d 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -771,6 +771,15 @@ help.format:: Values 'man', 'info', 'web' and 'html' are supported. 'man' is the default. 'web' and 'html' are the same. +help.autocorrect:: + Automatically correct and execute mistyped commands after + waiting for the given number of deciseconds (0.1 sec). If more + than one command can be deduced from the entered text, nothing + will be executed. If the value of this option is negative, + the corrected command will be executed immediately. If the + value is 0 - the command will be just shown but not executed. + This is the default. + http.proxy:: Override the HTTP proxy, normally configured using the 'http_proxy' environment variable (see linkgit:curl[1]). This can be overridden diff --git a/help.c b/help.c index 8b25a55..4d52781 100644 --- a/help.c +++ b/help.c @@ -271,7 +271,7 @@ static int git_help_config(const char *var, const char *value, void *cb) if (!prefixcmp(var, "man.")) return add_man_viewer_info(var, value); if (!strcmp(var, "help.autocorrect")) - autocorrect = git_config_bool(var,value); + autocorrect = git_config_int(var,value); return git_default_config(var, value, cb); } @@ -722,6 +722,11 @@ const char *help_unknown_cmd(const char *cmd) "which does not exist.\n" "Continuing under the assumption that you meant '%s'\n", cmd, main_cmds.names[0]->name); + if (autocorrect > 0) { + fprintf(stderr, "in %0.1f seconds automatically...\n", + (float)autocorrect/10.0); + poll(NULL, 0, autocorrect * 100); + } return main_cmds.names[0]->name; }
-- 1.6.0.rc0.50.g9c23