summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-05-12 16:02:18 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-05-12 16:02:18 -0400
commit9465bedb097078355ea4131a839d15f242cd4652 (patch)
tree8dfbb1b306b2eddd682f9b2960a76a415d882c9a
parent30e629a0731e205f544205b7900b4d5083e57f08 (diff)
downloadlibgit2-9465bedb097078355ea4131a839d15f242cd4652.tar.gz
attr: don't mangle file path during attr matching
When determining whether some file matches an attr pattern, do not try to truncate the path to pass to fnmatch. When there is no containing directory for an item (eg, from a .gitignore in the root) this will cause us to truncate our path, which means that we cannot do meaningful comparisons on it and we may have false positives when trying to determine whether a given file is actually a file or a folder (as we have lost the path's base information.) This mangling was to allow fnmatch to compare a directory on disk to the name of a directory, but it is unnecessary as our fnmatch accepts FNM_LEADING_DIR.
-rw-r--r--src/attr_file.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index a7cc5916d..5ec5b4408 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -401,10 +401,9 @@ bool git_attr_fnmatch__match(
path->basename == path->path)
return false;
- /* for ignore checks, use container of current item for check */
- path->basename[-1] = '\0';
flags |= FNM_LEADING_DIR;
+ /* for ignore checks, use container of current item for check */
if (match->containing_dir)
matchpath = path->basename;
else
@@ -419,7 +418,7 @@ bool git_attr_fnmatch__match(
return false;
matchval = p_fnmatch(match->pattern, matchpath, flags);
- path->basename[-1] = '/';
+
return (matchval != FNM_NOMATCH);
}