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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---

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


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]