From decd70079244e8daa16eb49c95f82c407629b540 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Thu, 9 Aug 2007 23:07:30 +0200 Subject: [PATCH] Use is_absolute_path() in more places. --- builtin-init-db.c | 2 +- config.c | 2 +- exec_cmd.c | 12 ++---------- git.c | 14 ++++---------- setup.c | 5 +---- 5 files changed, 9 insertions(+), 26 deletions(-) diff --git a/builtin-init-db.c b/builtin-init-db.c index 2a20737249..c51c586141 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -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); diff --git a/config.c b/config.c index fb4576f87f..78bd267070 100644 --- a/config.c +++ b/config.c @@ -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); diff --git a/exec_cmd.c b/exec_cmd.c index a9886b87fd..bad4843113 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -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", diff --git a/git.c b/git.c index adbc188d86..9908a60007 100644 --- a/git.c +++ b/git.c @@ -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: diff --git a/setup.c b/setup.c index fa5f724d21..15100bc1b7 100644 --- a/setup.c +++ b/setup.c @@ -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