diff options
author | Russell Belfer <arrbee@arrbee.com> | 2012-01-31 13:59:32 -0800 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2012-01-31 13:59:32 -0800 |
commit | adc9bdb3b1428b8edf067ab17c26ef15ec1ac8a7 (patch) | |
tree | 779de1400c8c3385ab21fde0bac47b96081c50aa /src/attr_file.c | |
parent | 5d3cd4e309517a8ab2b553ad0839493ba45bb97d (diff) | |
download | libgit2-adc9bdb3b1428b8edf067ab17c26ef15ec1ac8a7.tar.gz |
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.
Diffstat (limited to 'src/attr_file.c')
-rw-r--r-- | src/attr_file.c | 12 |
1 files changed, 11 insertions, 1 deletions
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; } |