diff --git a/cache.h b/cache.h index e0a5f6decd..91e9f7109f 100644 --- a/cache.h +++ b/cache.h @@ -359,6 +359,10 @@ int git_config_perm(const char *var, const char *value); int adjust_shared_perm(const char *path); int safe_create_leading_directories(char *path); char *enter_repo(char *path, int strict); +static inline int is_absolute_path(const char *path) +{ + return path[0] == '/' || (isalpha(path[0]) && path[1] == ':'); +} /* Read and unpack a sha1 file into memory, write memory to a sha1 file */ extern int sha1_object_info(const unsigned char *, unsigned long *); diff --git a/trace.c b/trace.c index 7961a27a2e..344066e88b 100644 --- a/trace.c +++ b/trace.c @@ -64,7 +64,7 @@ static int get_trace_fd(int *need_close) return STDERR_FILENO; if (strlen(trace) == 1 && isdigit(*trace)) return atoi(trace); - if (*trace == '/') { + if (is_absolute_path(trace)) { int fd = open(trace, O_WRONLY | O_APPEND | O_CREAT, 0666); if (fd == -1) { fprintf(stderr,