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

[PATCH] help.c: don't blame an user's typo when the system is at fault

From
Michele Ballabio <barra_cuda@katamail.com>
Date
Jul 20, 2009, 13:45 UTC
Message-ID
<200907201545.06030.barra_cuda@katamail.com>
In-Reply-To
<alpine.DEB.2.00.0907201309150.5423@ds9.cixit.se>
As reported by Peter Krefting:
  If git cannot start one of the external commands (at least some of them),
  the DWIM engine is a bit flaky:
     $ git citool
     /usr/local/libexec/git-core/git-citool: line 10: exec: wish: not found
     git: 'citool' is not a git-command. See 'git --help'.
     Did you mean this?
         citool

Now we check whether the best bet found by levenshtein() differs from the command line or not before proceeding.

The new error is:

$ git citool /usr/local/libexec/git-core/git-citool: line 10: exec: wish: not found fatal: Failed to run command 'citool': No such file or directory

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
---
Is the call to strerror() useless anyway?
 help.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/help.c b/help.c
index fd87bb5..eec62a3 100644
--- a/help.c
+++ b/help.c
@@ -325,6 +325,9 @@ const char *help_unknown_cmd(const char *cmd)
 
 	if (!main_cmds.cnt)
 		die ("Uh oh. Your system reports no Git commands at all.");
+	if (!strcmp(cmd, main_cmds.names[0]->name))
+		die("Failed to run command '%s': %s\n",
+			cmd, strerror(errno));
 
 	best_similarity = main_cmds.names[0]->len;
 	n = 1;
-- 
1.6.3.1.17.g076c3
Previous: Peter KreftingNext: Thomas Rast
Message 2 of 4 in “Bad DWIM response when git gui cannot start”
  1. Peter KreftingJul 20, 2009
  2. help.c: don't blame an user's typo when the system is at faultMichele Ballabio, Jul 20, 2009
  3. Thomas RastJul 20, 2009
  4. Jeff KingJul 20, 2009

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.