[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?
citoolNow 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