summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorLibravatar Nguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-02-09 07:26:37 +0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-02-10 11:49:53 -0800
commit16402b992e0332d2ac68106f4488b47175bf0a13 (patch)
tree1eedc82db674252cf0223b3882177631f2221336 /dir.c
parentGit 1.8.5.4 (diff)
downloadtgif-16402b992e0332d2ac68106f4488b47175bf0a13.tar.xz
dir: warn about trailing spaces in exclude patterns
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index 23b6de4703..065491bb4b 100644
--- a/dir.c
+++ b/dir.c
@@ -463,6 +463,22 @@ void clear_exclude_list(struct exclude_list *el)
el->filebuf = NULL;
}
+static void check_trailing_spaces(const char *fname, char *buf)
+{
+ int i, last_space = -1, len = strlen(buf);
+ for (i = 0; i < len; i++)
+ if (buf[i] == '\\')
+ i++;
+ else if (buf[i] == ' ')
+ last_space = i;
+ else
+ last_space = -1;
+
+ if (last_space == len - 1)
+ warning(_("%s: trailing spaces in '%s'. Please quote or remove them."),
+ fname, buf);
+}
+
int add_excludes_from_file_to_list(const char *fname,
const char *base,
int baselen,
@@ -514,6 +530,7 @@ int add_excludes_from_file_to_list(const char *fname,
if (buf[i] == '\n') {
if (entry != buf + i && entry[0] != '#') {
buf[i - (i && buf[i-1] == '\r')] = 0;
+ check_trailing_spaces(fname, entry);
add_exclude(entry, base, baselen, el, lineno);
}
lineno++;