git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[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
Previous: Junio C HamanoNext: Johannes Schindelin
Message 16 of 20 in “git wrapper: DWIM mistyped commands”
  1. git wrapper: DWIM mistyped commandsJohannes Schindelin, Jul 22, 2008
  2. [SCNR] Re: [FYI PATCH] git wrapper: DWIM mistyped commandsPierre Habouzit, Jul 22, 2008
  3. Johannes SchindelinJul 22, 2008
  4. Pierre HabouzitJul 22, 2008
  5. Alex RiesenJul 22, 2008
  6. Add help.autocorrect to enable/disable autocorrectingAlex Riesen, Jul 22, 2008
  7. Johannes SchindelinJul 22, 2008
  8. Add help.autocorrect to enable/disable autocorrectingAlex Riesen, Jul 22, 2008
  9. Johannes SchindelinJul 22, 2008
  10. Add help.autocorrect to enable/disable autocorrectingAlex Riesen, Jul 22, 2008
  11. Johannes SchindelinJul 23, 2008
  12. Alex RiesenJul 23, 2008
  13. Johannes SchindelinJul 23, 2008
  14. Johannes SchindelinJul 23, 2008
  15. Junio C HamanoJul 22, 2008
  16. Wait help.autocorrect deciseconds before running corrected commandAlex Riesen, Jul 23, 2008
  17. Johannes SchindelinJul 23, 2008
  18. Alex RiesenJul 23, 2008
  19. Junio C HamanoJul 22, 2008
  20. Sverre RabbelierJul 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.