Merge branch 'jc/maint-sane-execvp-notdir'
authorJunio C Hamano <gitster@pobox.com>
Mon, 3 Sep 2012 22:53:26 +0000 (15:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Sep 2012 22:53:26 +0000 (15:53 -0700)
"git foo" errored out with "Not a directory" when the user had a non
directory on $PATH, and worse yet it masked an alias "foo" to run.

* jc/maint-sane-execvp-notdir:
sane_execvp(): ignore non-directory on $PATH

run-command.c
index 606791dc674a1d24459d85504f0c981634b52020..f9922b9ecc8e4956e19d7143bb6cb6ef4d97abf8 100644 (file)
@@ -139,6 +139,8 @@ int sane_execvp(const char *file, char * const argv[])
         */
        if (errno == EACCES && !strchr(file, '/'))
                errno = exists_in_PATH(file) ? EACCES : ENOENT;
+       else if (errno == ENOTDIR && !strchr(file, '/'))
+               errno = ENOENT;
        return -1;
 }