From a51cd8e6f6724079a552b75e014f792f3f68e158 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 16 Jan 2012 16:58:27 -0800 Subject: Fix handling of relative paths for attrs Per issue #533, the handling of relative paths in attribute and ignore files was not right. Fixed this by pre-joining the relative path of the attribute/ignore file onto the match string when a full path match is required. Unfortunately, fixing this required a bit more code than I would have liked because I had to juggle things around so that the fnmatch parser would have sufficient information to prepend the relative path when it was needed. --- src/attr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/attr.c') diff --git a/src/attr.c b/src/attr.c index dc42379ff..3fe76d124 100644 --- a/src/attr.c +++ b/src/attr.c @@ -214,7 +214,7 @@ int git_attr_cache__push_file( git_vector *stack, const char *base, const char *filename, - int (*loader)(git_repository *, const char *, git_attr_file **)) + int (*loader)(git_repository *, const char *, git_attr_file *)) { int error = GIT_SUCCESS; git_attr_cache *cache = &repo->attrcache; @@ -231,11 +231,12 @@ int git_attr_cache__push_file( /* either get attr_file from cache or read from disk */ file = git_hashtable_lookup(cache->files, filename); if (file == NULL && git_futils_exists(filename) == GIT_SUCCESS) { - error = (*loader)(repo, filename, &file); + if ((error = git_attr_file__new(&file)) == GIT_SUCCESS) + error = (*loader)(repo, filename, file); add_to_cache = (error == GIT_SUCCESS); } - if (file != NULL) { + if (error == GIT_SUCCESS && file != NULL) { /* add file to vector, if we found it */ error = git_vector_insert(stack, file); -- cgit v1.2.1 From 83bfbdf593a76c591bb9cbd40cec6fca36c81a9c Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 16 Jan 2012 18:00:18 -0800 Subject: Remove poor git__removechar function Going back over this, the git__removechar function was not needed (only invoked once) and is actually mislabeled. As implemented, it really only made sense for removing backslash characters, since two of the "removed" characters in a row would include the second one -- i.e. it really implements stripping backslash-escaped strings where a backslash allows internal whitespace in a word. --- src/attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/attr.c') diff --git a/src/attr.c b/src/attr.c index 3fe76d124..fa1a4f121 100644 --- a/src/attr.c +++ b/src/attr.c @@ -232,7 +232,7 @@ int git_attr_cache__push_file( file = git_hashtable_lookup(cache->files, filename); if (file == NULL && git_futils_exists(filename) == GIT_SUCCESS) { if ((error = git_attr_file__new(&file)) == GIT_SUCCESS) - error = (*loader)(repo, filename, file); + error = loader(repo, filename, file); add_to_cache = (error == GIT_SUCCESS); } -- cgit v1.2.1