attr: Cleanup the containing dir logic

parent 62595764
...@@ -411,7 +411,7 @@ static int collect_attr_files( ...@@ -411,7 +411,7 @@ static int collect_attr_files(
const char *path, const char *path,
git_vector *files) git_vector *files)
{ {
int error; int error = 0;
git_buf dir = GIT_BUF_INIT; git_buf dir = GIT_BUF_INIT;
const char *workdir = git_repository_workdir(repo); const char *workdir = git_repository_workdir(repo);
attr_walk_up_info info = { NULL }; attr_walk_up_info info = { NULL };
...@@ -422,12 +422,12 @@ static int collect_attr_files( ...@@ -422,12 +422,12 @@ static int collect_attr_files(
/* Resolve path in a non-bare repo */ /* Resolve path in a non-bare repo */
if (workdir != NULL) if (workdir != NULL)
error = git_path_find_dir(&dir, path, workdir); error = git_path_find_dir(&dir, path, workdir);
else /* when in a bare repo, find the containing folder if the given
error = git_path_dirname_r(&dir, path); * 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) if (error < 0)
goto cleanup; goto cleanup;
if (dir.size == 1 && dir.ptr[0] == '.')
git_buf_clear(&dir);
/* in precendence order highest to lowest: /* in precendence order highest to lowest:
* - $GIT_DIR/info/attributes * - $GIT_DIR/info/attributes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment