查看git的源码,git.c中有一条注释:
/*
* We use PATH to find git commands, but we prepend some higher
* precedence paths: the "--exec-path" option, the GIT_EXEC_PATH
* environment, and the $(gitexecdir) from the Makefile at build
* time.
*/
如果你打电话git --exec-path
,你最终打电话const char *git_exec_path(void)
in exec_cmd.c http://github.com/git/git/blob/master/exec_cmd.c#L72。看起来像这样:
const char *env;
if (argv_exec_path)
return argv_exec_path;
env = getenv(EXEC_PATH_ENVIRONMENT);
if (env && *env) {
return env;
}
return system_path(GIT_EXEC_PATH);
现在,当您说时 _argv_exec_path_ 已设置--exec-path=/some/where
所以可以打折。你已经说过环境变量没有设置。GIT_EXEC_PATH
是在编译期间定义的Makefile http://github.com/git/git/blob/master/Makefile#L1508。倒退一下,它似乎被定义为libexec/git-core
。所以,我们需要看看什么系统路径() http://github.com/git/git/blob/master/exec_cmd.c#L10相反。
我不确定是否RUNTIME_PREFIX
已为您定义。但是在查看 Makefile 时,我确实注意到prefix http://github.com/git/git/blob/master/Makefile#L231默认为$(HOME)
。我怀疑这可能是您出现问题的原因。
简单的答案是将其放入~/.bashrc
:
export GIT_EXEC_PATH=/opt/local/libexec/git-core
如果你想了解更多关于正在发生的事情,你可能需要使用以下命令重新编译 gitport -d upgrade -f git-core
(或类似的)并仔细查看构建日志以查看前缀的设置位置。顺便,port cat git-core
显示大量使用${prefix}
所以它应该(希望)是显而易见的。