Use is_absolute_path() in more places.

This commit is contained in:
Johannes Sixt
2007-08-09 23:07:30 +02:00
parent 37ebf62c74
commit decd700792
5 changed files with 9 additions and 26 deletions

View File

@@ -140,7 +140,7 @@ static void copy_templates(const char *git_dir, int len, const char *template_di
* interpreted relative to the exec_dir
*/
template_dir = DEFAULT_GIT_TEMPLATE_DIR;
if (template_dir[0] != '/' && template_dir[1] != ':') {
if (!is_absolute_path(template_dir)) {
const char *exec_path = git_exec_path();
template_dir = prefix_path(exec_path, strlen(exec_path),
template_dir);

View File

@@ -454,7 +454,7 @@ const char *git_etc_gitconfig(void)
if (!system_wide) {
system_wide = ETC_GITCONFIG;
/* interpret path relative to exec-dir */
if (system_wide[0] != '/' && system_wide[1] != ':') {
if (!is_absolute_path(system_wide)) {
const char *exec_path = git_exec_path();
system_wide = prefix_path(exec_path, strlen(exec_path),
system_wide);

View File

@@ -80,11 +80,7 @@ int execv_git_cmd(const char **argv)
if (!exec_dir || !*exec_dir) continue;
#ifdef __MINGW32__
if (*exec_dir != '/' && exec_dir[1] != ':') {
#else
if (*exec_dir != '/') {
#endif
if (!is_absolute_path(exec_dir)) {
if (!getcwd(git_command, sizeof(git_command))) {
fprintf(stderr, "git: cannot determine "
"current directory: %s\n",
@@ -190,11 +186,7 @@ int spawnv_git_cmd(const char **argv, int pin[2], int pout[2])
if (!exec_dir || !*exec_dir) continue;
#ifdef __MINGW32__
if (*exec_dir != '/' && exec_dir[1] != ':') {
#else
if (*exec_dir != '/') {
#endif
if (!is_absolute_path(exec_dir)) {
if (!getcwd(p[i], sizeof(p[i]))) {
fprintf(stderr, "git: cannot determine "
"current directory: %s\n",

14
git.c
View File

@@ -422,22 +422,16 @@ int main(int argc, const char **argv)
* if it's an absolute path and we don't have
* anything better.
*/
if (slash) {
*slash++ = 0;
if (*cmd == '/')
exec_path = cmd;
cmd = slash;
}
#ifdef __MINGW32__
slash = strrchr(cmd, '\\');
if (!slash)
slash = strrchr(cmd, '\\');
#endif
if (slash) {
*slash++ = 0;
if (cmd[1] == ':')
if (is_absolute_path(cmd))
exec_path = cmd;
cmd = slash;
}
#endif
/*
* "git-xxxx" is the same as "git xxxx", but we obviously:

View File

@@ -88,10 +88,7 @@ const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
return arg;
#else
/* don't add prefix to absolute paths */
const int is_absolute =
is_dir_sep(arg[0]) ||
(arg[0] && arg[1] == ':' && is_dir_sep(arg[2]));
if (is_absolute)
if (is_absolute_path(arg))
pfx_len = 0;
else
#endif