summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe rugged tests are fragile <tanoku@gmail.com>2014-09-17 15:23:17 +0200
committerThe rugged tests are fragile <tanoku@gmail.com>2014-09-17 15:24:17 +0200
commita2b4407dc3d4e1ecc5b908c3fff56dc207c7c4e6 (patch)
tree91479ae9fc840f3666130a8ce444a42f4d1c1545
parent4cb7c4a4c7945c328c2e26e116dd46c49d1654ef (diff)
downloadlibgit2-a2b4407dc3d4e1ecc5b908c3fff56dc207c7c4e6.tar.gz
attr: Do not walk path if we're at the root
-rw-r--r--src/attr.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/attr.c b/src/attr.c
index fd0ab9274..e4bd5f669 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -422,10 +422,8 @@ static int collect_attr_files(
/* Resolve path in a non-bare repo */
if (workdir != NULL)
error = git_path_find_dir(&dir, path, workdir);
- /* 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);
+ else
+ error = git_path_dirname_r(&dir, path);
if (error < 0)
goto cleanup;
@@ -449,7 +447,12 @@ static int collect_attr_files(
giterr_clear(); /* no error even if there is no index */
info.files = files;
- error = git_path_walk_up(&dir, workdir, push_one_attr, &info);
+ if (!strcmp(dir.ptr, ".")) {
+ error = push_one_attr(&info, "");
+ } else {
+ error = git_path_walk_up(&dir, workdir, push_one_attr, &info);
+ }
+
if (error < 0)
goto cleanup;