struct stat st;
int fd, i, lineno = 1;
size_t size = 0;
+ static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
char *buf, *entry;
fd = open(fname, O_RDONLY);
}
el->filebuf = buf;
- entry = buf;
+
+ if (size >= 3 && !memcmp(buf, utf8_bom, 3))
+ entry = buf + 3;
+ else
+ entry = buf;
+
for (i = 0; i < size; i++) {
if (buf[i] == '\n') {
if (entry != buf + i && entry[0] != '#') {
test_cmp expected actual
'
+test_expect_success 'same with gitignore starting with BOM' '
+ printf "\357\273\277ignored\n" >.gitignore &&
+ mkdir -p untracked &&
+ : >untracked/ignored &&
+ : >untracked/uncommitted &&
+ git status --porcelain --ignored >actual &&
+ test_cmp expected actual
+'
+
cat >expected <<\EOF
?? .gitignore
?? actual