From adc9bdb3b1428b8edf067ab17c26ef15ec1ac8a7 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 31 Jan 2012 13:59:32 -0800 Subject: Fix attr path is_dir check When building an attr path object, the code that checks if the file is a directory was evaluating the file as a relative path to the current working directory, instead of using the repo root. This lead to inconsistent behavior. --- src/attr_file.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/attr_file.c') diff --git a/src/attr_file.c b/src/attr_file.c index 5fd136c77..74b2b6d12 100644 --- a/src/attr_file.c +++ b/src/attr_file.c @@ -234,7 +234,7 @@ git_attr_assignment *git_attr_rule__lookup_assignment( } int git_attr_path__init( - git_attr_path *info, const char *path) + git_attr_path *info, const char *path, const char *base) { assert(info && path); info->path = path; @@ -243,7 +243,17 @@ int git_attr_path__init( info->basename++; if (!info->basename || !*info->basename) info->basename = path; + + if (base != NULL && git_path_root(path) < 0) { + git_buf full_path = GIT_BUF_INIT; + int error = git_buf_joinpath(&full_path, base, path); + if (error == GIT_SUCCESS) + info->is_dir = (git_path_isdir(full_path.ptr) == GIT_SUCCESS); + git_buf_free(&full_path); + return error; + } info->is_dir = (git_path_isdir(path) == GIT_SUCCESS); + return GIT_SUCCESS; } -- cgit v1.2.1