Skip to content

Commit

Permalink
Merge branch 'ms/help-unknown'
Browse files Browse the repository at this point in the history
* ms/help-unknown:
  help_unknown_cmd: do not propose an "unknown" cmd
  • Loading branch information
gitster committed Jul 22, 2011
2 parents b3743df + 823e0de commit c8409e7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions help.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit c8409e7

Please sign in to comment.