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,
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++;
echo "$response" | grep "^:: two"
'
+############################################################################
+#
+# test whitespace handling
+
+test_expect_success 'trailing whitespace is warned' '
+ mkdir whitespace &&
+ >whitespace/trailing &&
+ >whitespace/untracked &&
+ echo "whitespace/trailing " >ignore &&
+ cat >expect <<EOF &&
+whitespace/trailing
+whitespace/untracked
+EOF
+ git ls-files -o -X ignore whitespace >actual 2>err &&
+ grep "ignore:.*'\''whitespace/trailing '\''" err &&
+ test_cmp expect actual
+'
+
+test_expect_success 'quoting allows trailing whitespace' '
+ rm -rf whitespace &&
+ mkdir whitespace &&
+ >"whitespace/trailing " &&
+ >whitespace/untracked &&
+ echo "whitespace/trailing\\ \\ " >ignore &&
+ echo whitespace/untracked >expect &&
+ : >err.expect &&
+ git ls-files -o -X ignore whitespace >actual 2>err &&
+ test_cmp expect actual &&
+ test_cmp err.expect err
+'
+
test_done