aboutsummaryrefslogtreecommitdiff
path: root/attr.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-05-05 21:00:34 -0700
committerJunio C Hamano <gitster@pobox.com>2015-05-05 21:00:34 -0700
commit2e1dfd62dca9aecb0ec1bdf3d1927a8da6d95723 (patch)
tree6f556bbcfcb7fcecea0df2e1b116560a0f5569d7 /attr.c
parent39a5d50d62780e2f838e5fa8196c06fba2baa956 (diff)
parent27547e5fccda134560ad0441aa5bfa187387cec0 (diff)
downloadgit-2e1dfd62dca9aecb0ec1bdf3d1927a8da6d95723.tar.gz
git-2e1dfd62dca9aecb0ec1bdf3d1927a8da6d95723.tar.xz
Merge branch 'cn/bom-in-gitignore'
Teach the codepaths that read .gitignore and .gitattributes files that these files encoded in UTF-8 may have UTF-8 BOM marker at the beginning; this makes it in line with what we do for configuration files already. * cn/bom-in-gitignore: attr: skip UTF8 BOM at the beginning of the input file config: use utf8_bom[] from utf.[ch] in git_parse_source() utf8-bom: introduce skip_utf8_bom() helper add_excludes_from_file: clarify the bom skipping logic dir: allow a BOM at the beginning of exclude files
Diffstat (limited to 'attr.c')
-rw-r--r--attr.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/attr.c b/attr.c
index 1f9eebd2d..7f445965c 100644
--- a/attr.c
+++ b/attr.c
@@ -12,6 +12,7 @@
#include "exec_cmd.h"
#include "attr.h"
#include "dir.h"
+#include "utf8.h"
const char git_attr__true[] = "(builtin)true";
const char git_attr__false[] = "\0(builtin)false";
@@ -379,8 +380,12 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
return NULL;
}
res = xcalloc(1, sizeof(*res));
- while (fgets(buf, sizeof(buf), fp))
- handle_attr_line(res, buf, path, ++lineno, macro_ok);
+ while (fgets(buf, sizeof(buf), fp)) {
+ char *bufp = buf;
+ if (!lineno)
+ skip_utf8_bom(&bufp, strlen(bufp));
+ handle_attr_line(res, bufp, path, ++lineno, macro_ok);
+ }
fclose(fp);
return res;
}