summaryrefslogtreecommitdiff
path: root/src/attr_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/attr_file.c')
-rw-r--r--src/attr_file.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index b2c60f204..40262eca6 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -560,13 +560,15 @@ void git_attr_path__free(git_attr_path *info)
*/
/*
- * Determine the length of trailing spaces.
+ * Determine the length of trailing spaces. Escaped spaces do not count as
+ * trailing whitespace.
*/
static size_t trailing_space_length(const char *p, size_t len)
{
size_t n;
for (n = len; n; n--) {
- if (p[n-1] != ' ' && p[n-1] != '\t')
+ if ((p[n-1] != ' ' && p[n-1] != '\t') ||
+ (n > 1 && p[n-2] == '\\'))
break;
}
return len - n;