Merge branch 'ms/help-unknown'
authorJunio C Hamano <gitster@pobox.com>
Fri, 22 Jul 2011 21:43:21 +0000 (14:43 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 22 Jul 2011 21:43:21 +0000 (14:43 -0700)
* ms/help-unknown:
help_unknown_cmd: do not propose an "unknown" cmd

1  2 
help.c
diff --combined help.c
index e925ca1f8973a05a66b5c09b45e3451f65e3a1e7,42193550f0b6f2a2c703c20c7abf1a81fe1b51d0..cbbe966f685b276cac702bb0fd9a44bfbf5f0e79
--- 1/help.c
--- 2/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;
                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)