git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Michael Schubert <mschub@elegosoft.com>
Cc: git@vger.kernel.org, Alex Vandiver <alex@chmrr.net>
Subject: Re: Doesn't disambiguate between 'external command failed' and 'command not found'
Date: Tue, 5 Jul 2011 19:22:00 -0400	[thread overview]
Message-ID: <20110705232200.GD12085@sigill.intra.peff.net> (raw)
In-Reply-To: <20110705231604.GC12085@sigill.intra.peff.net>

On Tue, Jul 05, 2011 at 07:16:05PM -0400, Jeff King wrote:

> So if you are going to follow this strategy, you are probably better to
> just skip the entry (or give it a high levenshtein distance) in the main
> loop where we calculate candidates.

And here's what that would look like.

diff --git a/help.c b/help.c
index e925ca1..15e6f0b 100644
--- a/help.c
+++ b/help.c
@@ -329,6 +329,11 @@ const char *help_unknown_cmd(const char *cmd)
 		int cmp = 0; /* avoid compiler stupidity */
 		const char *candidate = main_cmds.names[i]->name;
 
+		if (!strcmp(candidate, cmd)) {
+			main_cmds.names[i]->len = SIMILARITY_FLOOR + 1;
+			continue;
+		}
+
 		/* Does the candidate appear in common_cmds list? */
 		while (n < ARRAY_SIZE(common_cmds) &&
 		       (cmp = strcmp(common_cmds[n].name, candidate)) < 0)

I suspect it can create its own brand of confusion, though:

  $ cat `which git-broken`
  #!/bin/bogus
  $ git broken
  git: 'broken' is not a git command. See 'git --help'.

At which point I search through my PATH and confirm that indeed,
"git-broken" _is_ a git command. And I'm left on my own to figure out
that it's a broken #!-line.

So I think I prefer giving some more specific advice. Even if we don't
mention "#!" lines explicitly, saying "This exists, but exec didn't
work" is probably more helpful than pretending it's not there. It gives
clueful people an idea of where to start looking for the problem.

-Peff

  reply	other threads:[~2011-07-05 23:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 16:49 Doesn't disambiguate between 'external command failed' and 'command not found' Alex Vandiver
2011-07-05 20:41 ` Michael Schubert
2011-07-05 23:16   ` Jeff King
2011-07-05 23:22     ` Jeff King [this message]
2011-07-06 11:24       ` Sverre Rabbelier
2011-07-06 11:47     ` Michael Schubert
2011-07-06 17:58       ` Jeff King
2011-07-06 18:00         ` Jeff King
2011-07-06 23:25           ` Junio C Hamano
2011-07-08 10:08             ` Michael Schubert
2011-07-08 16:52               ` Junio C Hamano
2011-07-06 17:24     ` Junio C Hamano
2011-07-06 17:56       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110705232200.GD12085@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=alex@chmrr.net \
    --cc=git@vger.kernel.org \
    --cc=mschub@elegosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).