summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe rugged tests are fragile <tanoku@gmail.com>2014-09-16 13:20:58 +0200
committerThe rugged tests are fragile <tanoku@gmail.com>2014-09-16 13:20:58 +0200
commit52e9120c777fba582a468323d2b94155a071f5ea (patch)
tree613d4b151dec5005154fadd785d52af77f45afdd
parent6259576408520a93f7a3da220454a6b540536d15 (diff)
downloadlibgit2-52e9120c777fba582a468323d2b94155a071f5ea.tar.gz
attr: Cleanup the containing dir logic
-rw-r--r--src/attr.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/attr.c b/src/attr.c
index 1decb5ba8..dee84b0ab 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -411,7 +411,7 @@ static int collect_attr_files(
const char *path,
git_vector *files)
{
- int error;
+ int error = 0;
git_buf dir = GIT_BUF_INIT;
const char *workdir = git_repository_workdir(repo);
attr_walk_up_info info = { NULL };
@@ -422,12 +422,12 @@ static int collect_attr_files(
/* Resolve path in a non-bare repo */
if (workdir != NULL)
error = git_path_find_dir(&dir, path, workdir);
- else
- error = git_path_dirname_r(&dir, path);
+ /* when in a bare repo, find the containing folder if the given
+ * path is a subfolder (if not, the containing folder is the root) */
+ else if (strchr(path, '/') != NULL)
+ error = git_path_dirname_r(&dir, path);
if (error < 0)
goto cleanup;
- if (dir.size == 1 && dir.ptr[0] == '.')
- git_buf_clear(&dir);
/* in precendence order highest to lowest:
* - $GIT_DIR/info/attributes