summaryrefslogtreecommitdiff
path: root/src/ignore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ignore.c')
-rw-r--r--src/ignore.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/ignore.c b/src/ignore.c
index aef3e39b4..5cf4fca5c 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -14,8 +14,7 @@ static int parse_ignore_file(
{
int error = 0;
git_attr_fnmatch *match = NULL;
- const char *scan = NULL;
- char *context = NULL;
+ const char *scan = NULL, *context = NULL;
int ignore_case = false;
/* Prefer to have the caller pass in a git_ignores as the parsedata
@@ -25,10 +24,10 @@ static int parse_ignore_file(
else if (git_repository__cvar(&ignore_case, repo, GIT_CVAR_IGNORECASE) < 0)
return error;
- if (ignores->key && git__suffixcmp(ignores->key, "/" GIT_IGNORE_FILE) == 0) {
+ if (ignores->key &&
+ git_path_root(ignores->key + 2) < 0 &&
+ git__suffixcmp(ignores->key, "/" GIT_IGNORE_FILE) == 0)
context = ignores->key + 2;
- context[strlen(context) - strlen(GIT_IGNORE_FILE)] = '\0';
- }
scan = buffer;
@@ -64,9 +63,6 @@ static int parse_ignore_file(
}
git__free(match);
- /* restore file path used for context */
- if (context)
- context[strlen(context)] = '.'; /* first char of GIT_IGNORE_FILE */
return error;
}