aboutsummaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-07-22 14:43:21 -0700
committerJunio C Hamano <gitster@pobox.com>2011-07-22 14:43:21 -0700
commitc8409e716a8a117ee37fb0c4b8ecbfcc4bac3fe9 (patch)
treee292fa81f2cfc69a0d78772383f2992807ebd3f8 /help.c
parentb3743df73f9e0238ea360b2a640e5e5c99517e9a (diff)
parent823e0ded8a319425496967dcb284e7e3ce2b6c29 (diff)
downloadgit-c8409e716a8a117ee37fb0c4b8ecbfcc4bac3fe9.tar.gz
git-c8409e716a8a117ee37fb0c4b8ecbfcc4bac3fe9.tar.xz
Merge branch 'ms/help-unknown'
* ms/help-unknown: help_unknown_cmd: do not propose an "unknown" cmd
Diffstat (limited to 'help.c')
-rw-r--r--help.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/help.c b/help.c
index e925ca1f8..cbbe966f6 100644
--- a/help.c
+++ b/help.c
@@ -305,6 +305,10 @@ static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old)
#define SIMILARITY_FLOOR 7
#define SIMILAR_ENOUGH(x) ((x) < SIMILARITY_FLOOR)
+static const char bad_interpreter_advice[] =
+ N_("'%s' appears to be a git command, but we were not\n"
+ "able to execute it. Maybe git-%s is broken?");
+
const char *help_unknown_cmd(const char *cmd)
{
int i, n, best_similarity = 0;
@@ -329,6 +333,14 @@ const char *help_unknown_cmd(const char *cmd)
int cmp = 0; /* avoid compiler stupidity */
const char *candidate = main_cmds.names[i]->name;
+ /*
+ * An exact match means we have the command, but
+ * for some reason exec'ing it gave us ENOENT; probably
+ * it's a bad interpreter in the #! line.
+ */
+ if (!strcmp(candidate, cmd))
+ die(_(bad_interpreter_advice), cmd, cmd);
+
/* Does the candidate appear in common_cmds list? */
while (n < ARRAY_SIZE(common_cmds) &&
(cmp = strcmp(common_cmds[n].name, candidate)) < 0)