Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-04-26 21:51:45 +0400
committerRussell Belfer <rb@github.com>2012-04-26 21:51:45 +0400
commitd58336dda873704f8d12a8b78c3191deefa4ec14 (patch)
tree84137abc698a572015d41975ced985fc0bd77e61 /src/attr.c
parenteb3d71a5bcd78cb4840e62194e8998141508af88 (diff)
Fix leading slash behavior in attrs/ignores
We were not following the git behavior for leading slashes in path names when matching git ignores and git attribute file patterns. This should fix issue #638.
Diffstat (limited to 'src/attr.c')
-rw-r--r--src/attr.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/attr.c b/src/attr.c
index 3e3a7e749..120d12737 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -23,10 +23,11 @@ int git_attr_get(
*value = NULL;
- if ((error = git_attr_path__init(
- &path, pathname, git_repository_workdir(repo))) < 0 ||
- (error = collect_attr_files(repo, pathname, &files)) < 0)
- return error;
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
+ return -1;
+
+ if ((error = collect_attr_files(repo, pathname, &files)) < 0)
+ goto cleanup;
attr.name = name;
attr.name_hash = git_attr_file__name_hash(name);
@@ -38,13 +39,14 @@ int git_attr_get(
if (pos >= 0) {
*value = ((git_attr_assignment *)git_vector_get(
&rule->assigns, pos))->value;
- goto found;
+ goto cleanup;
}
}
}
-found:
+cleanup:
git_vector_free(&files);
+ git_attr_path__free(&path);
return error;
}
@@ -70,10 +72,11 @@ int git_attr_get_many(
memset((void *)values, 0, sizeof(const char *) * num_attr);
- if ((error = git_attr_path__init(
- &path, pathname, git_repository_workdir(repo))) < 0 ||
- (error = collect_attr_files(repo, pathname, &files)) < 0)
- return error;
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
+ return -1;
+
+ if ((error = collect_attr_files(repo, pathname, &files)) < 0)
+ goto cleanup;
info = git__calloc(num_attr, sizeof(attr_get_many_info));
GITERR_CHECK_ALLOC(info);
@@ -108,6 +111,7 @@ int git_attr_get_many(
cleanup:
git_vector_free(&files);
+ git_attr_path__free(&path);
git__free(info);
return error;
@@ -128,10 +132,11 @@ int git_attr_foreach(
git_attr_assignment *assign;
git_strmap *seen = NULL;
- if ((error = git_attr_path__init(
- &path, pathname, git_repository_workdir(repo))) < 0 ||
- (error = collect_attr_files(repo, pathname, &files)) < 0)
- return error;
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
+ return -1;
+
+ if ((error = collect_attr_files(repo, pathname, &files)) < 0)
+ goto cleanup;
seen = git_strmap_alloc();
GITERR_CHECK_ALLOC(seen);
@@ -158,6 +163,7 @@ int git_attr_foreach(
cleanup:
git_strmap_free(seen);
git_vector_free(&files);
+ git_attr_path__free(&path);
return error;
}