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

[PATCH] Add help.autocorrect to enable/disable autocorrecting

From
Alex Riesen <raa.lkml@gmail.com>
Date
Jul 22, 2008, 21:03 UTC
Message-ID
<20080722210354.GD5113@blimp.local>
In-Reply-To
<20080722203730.GC5113@blimp.local>
It is off by default, to avoid scaring people unless they asked to.
---
Alex Riesen, Tue, Jul 22, 2008 22:37:30 +0200:
Show 15 quoted lines
> Johannes Schindelin, Tue, Jul 22, 2008 22:01:29 +0200:
> > As a convenience, if there is only one candidate, Git continues under
> > the assumption that the user mistyped it.  Example:
> > 
> > 	$ git reabse
> > 	WARNING: You called a Git program named 'reabse', which does
> > 	not exist.
> > 	Continuing under the assumption that you meant 'rebase'
> > 	[...]
> 
> Oh, that would make me suspicios (and I hit Ctrl-C fast when I get
> suspicios about what happens to my precious data). Could it be
> configurable? For example, BASH's cdspell is configurable and even off
> by default.
> 
Like this, perhaps?
 help.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/help.c b/help.c
index 480befe..f08eb9d 100644
--- a/help.c
+++ b/help.c
@@ -28,6 +28,7 @@ enum help_format {
 	HELP_FORMAT_WEB,
 };
 
+static int autocorrect;
 static int show_all = 0;
 static enum help_format help_format = HELP_FORMAT_MAN;
 static struct option builtin_help_options[] = {
@@ -269,6 +270,8 @@ 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);
 
 	return git_default_config(var, value, cb);
 }
@@ -704,9 +707,10 @@ const char *help_unknown_cmd(const char *cmd)
 
 	if (!main_cmds.cnt)
 		die ("Uh oh.  Your system reports no Git commands at all.");
+	git_config(git_help_config, NULL);
 	best_similarity = similarity(main_cmds.names[0]->name);
-	if (main_cmds.cnt < 2 || best_similarity <
-			similarity(main_cmds.names[1]->name)) {
+	if (autocorrect && (main_cmds.cnt < 2 ||
+		best_similarity < similarity(main_cmds.names[1]->name))) {
 		if (!*cwd)
 			exit(1);
 		if (chdir(cwd))
-- 
1.6.0.rc0.48.g6dda.dirty
Previous: Alex RiesenNext: Johannes Schindelin
Message 6 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.