From: Junio C Hamano Date: Fri, 22 Jul 2011 21:43:21 +0000 (-0700) Subject: Merge branch 'ms/help-unknown' X-Git-Tag: v1.7.7-rc0~77 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c8409e716a8a117ee37fb0c4b8ecbfcc4bac3fe9?hp=-c Merge branch 'ms/help-unknown' * ms/help-unknown: help_unknown_cmd: do not propose an "unknown" cmd --- c8409e716a8a117ee37fb0c4b8ecbfcc4bac3fe9 diff --combined help.c index e925ca1f89,42193550f0..cbbe966f68 --- a/help.c +++ b/help.c @@@ -127,10 -127,7 +127,10 @@@ static int is_executable(const char *na !S_ISREG(st.st_mode)) return 0; -#ifdef WIN32 +#if defined(WIN32) || defined(__CYGWIN__) +#if defined(__CYGWIN__) +if ((st.st_mode & S_IXUSR) == 0) +#endif { /* cannot trust the executable bit, peek into the file instead */ char buf[3] = { 0 }; int n; @@@ -305,6 -302,10 +305,10 @@@ static void add_cmd_list(struct cmdname #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 -330,14 +333,14 @@@ 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)