Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
sane_execvp(): ignore non-directory on $PATH
author
Junio C Hamano
<gitster@pobox.com>
Tue, 31 Jul 2012 19:51:30 +0000
(12:51 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 31 Jul 2012 19:51:30 +0000
(12:51 -0700)
When you have a non-directory on your PATH, a funny thing happens:
$ PATH=$PATH:/bin/sh git foo
fatal: cannot exec 'git-foo': Not a directory?
Worse yet, as real commands always take precedence over aliases,
this behaviour interacts rather badly with them:
$ PATH=$PATH:/bin/sh git -c alias.foo=show git foo -s
fatal: cannot exec 'git-foo': Not a directory?
This is because an ENOTDIR error from the underlying execvp(2) is
reported back to the caller of our sane_execvp() wrapper as-is.
Translating it to ENOENT, just like the case where we _might_ have
the command in an unreadable directory, fixes it. Without an alias,
we would get
git: 'foo' is not a git command. See 'git --help'.
and we use the 'foo' alias when it is available, of course.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
run-command.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
38f865c
)
diff --git
a/run-command.c
b/run-command.c
index 805d41f93d66b9147b837fb51f365e85f8f44fda..f9b7db23857a31ee037b0f900d0a5f2397c3d538 100644
(file)
--- a/
run-command.c
+++ b/
run-command.c
@@
-77,6
+77,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;
}