summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-05-19 13:12:47 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2019-05-19 13:12:47 +0100
commite269b34319664cd65d45875f11f3e1b8f7179428 (patch)
tree6ef45b817fb2896496fa07d1b51e77fb5022754a
parente6e6b60f350da2165511c04706eb7e32481394ad (diff)
downloadlibgit2-ethomson/ignore_leading_slash.tar.gz
ignore: only skip first leading slashethomson/ignore_leading_slash
For compatibility with git, only skip the first leading slash in an ignore file. That is: `/a.txt` indicates to ignore a file named `a.txt` at the root. However `//b.txt` does not indicate that a file named `b.txt` at the root should be ignored.
-rw-r--r--src/attr_file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index 8619647a3..6042da2ba 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -604,7 +604,8 @@ int git_attr_fnmatch__parse(
if (*scan == '/') {
spec->flags = spec->flags | GIT_ATTR_FNMATCH_FULLPATH;
slash_count++;
- if (pattern == scan)
+
+ if (slash_count == 1 && pattern == scan)
pattern++;
}
/* remember if we see an unescaped wildcard in pattern */