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:
authoryorah <yoram.harmelin@gmail.com>2013-04-11 19:29:05 +0400
committeryorah <yoram.harmelin@gmail.com>2013-04-15 18:39:56 +0400
commit2e40a60e847d6c128af23e24ea7a8efebd2427da (patch)
tree398dabc6825bc63f578d39069a7a097f705bbf15 /src/attr_file.c
parent2d2260da41ddf22fd5c5f0c39ce16fad1548f29e (diff)
status: fix handling of filenames with special prefixes
Fix libgit2/libgit2sharp#379
Diffstat (limited to 'src/attr_file.c')
-rw-r--r--src/attr_file.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index 85cd87624..93f6df1d9 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -85,7 +85,7 @@ int git_attr_file__parse_buffer(
}
/* parse the next "pattern attr attr attr" line */
- if (!(error = git_attr_fnmatch__parse(
+ if (!(error = git_attr_fnmatch__parse_gitattr_format(
&rule->match, attrs->pool, context, &scan)) &&
!(error = git_attr_assignment__parse(
repo, attrs->pool, &rule->assigns, &scan)))
@@ -337,23 +337,16 @@ void git_attr_path__free(git_attr_path *info)
* GIT_ENOTFOUND if the fnmatch does not require matching, or
* another error code there was an actual problem.
*/
-int git_attr_fnmatch__parse(
+int git_attr_fnmatch__parse_gitattr_format(
git_attr_fnmatch *spec,
git_pool *pool,
const char *source,
const char **base)
{
- const char *pattern, *scan;
- int slash_count, allow_space;
+ const char *pattern;
assert(spec && base && *base);
- if (parse_optimized_patterns(spec, pool, *base))
- return 0;
-
- spec->flags = (spec->flags & GIT_ATTR_FNMATCH_ALLOWSPACE);
- allow_space = (spec->flags != 0);
-
pattern = *base;
while (git__isspace(*pattern)) pattern++;
@@ -375,6 +368,39 @@ int git_attr_fnmatch__parse(
pattern++;
}
+ if (git_attr_fnmatch__parse_shellglob_format(spec, pool,
+ source, &pattern) < 0)
+ return -1;
+
+ *base = pattern;
+
+ return 0;
+}
+
+/*
+ * Fills a spec for the purpose of pure pathspec matching, not
+ * related to a gitattribute file parsing.
+ *
+ * This will return 0 if the spec was filled out, or
+ * another error code there was an actual problem.
+ */
+int git_attr_fnmatch__parse_shellglob_format(
+ git_attr_fnmatch *spec,
+ git_pool *pool,
+ const char *source,
+ const char **base)
+{
+ const char *pattern, *scan;
+ int slash_count, allow_space;
+
+ assert(spec && base && *base);
+
+ if (parse_optimized_patterns(spec, pool, *base))
+ return 0;
+
+ allow_space = (spec->flags & GIT_ATTR_FNMATCH_ALLOWSPACE) != 0;
+ pattern = *base;
+
slash_count = 0;
for (scan = pattern; *scan != '\0'; ++scan) {
/* scan until (non-escaped) white space */
@@ -609,6 +635,7 @@ static void git_attr_rule__clear(git_attr_rule *rule)
/* match.pattern is stored in a git_pool, so no need to free */
rule->match.pattern = NULL;
rule->match.length = 0;
+ rule->match.flags = 0;
}
void git_attr_rule__free(git_attr_rule *rule)