diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-04-16 10:48:58 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-04-16 11:35:38 -0700 |
commit | 27547e5fccda134560ad0441aa5bfa187387cec0 (patch) | |
tree | d35c6fd87e15a685d0fefef6625a450ba5ba34df /attr.c | |
parent | 599446dc323d15bab7f2a54f57ae8c5c4d7d6103 (diff) | |
download | git-27547e5fccda134560ad0441aa5bfa187387cec0.tar.gz |
attr: skip UTF8 BOM at the beginning of the input filecn/bom-in-gitignore
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'attr.c')
-rw-r--r-- | attr.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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"; @@ -369,8 +370,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; } |