aboutsummaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
Diffstat (limited to 'help.c')
-rw-r--r--help.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/help.c b/help.c
index 7654f1bfd..cbbe966f6 100644
--- a/help.c
+++ b/help.c
@@ -127,7 +127,10 @@ static int is_executable(const char *name)
!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;
@@ -302,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;
@@ -326,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)