aboutsummaryrefslogtreecommitdiffstats
path: root/utf8.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 /utf8.c
parentMerge branch 'jc/epochtime-wo-tz' (diff)
parentattr: skip UTF8 BOM at the beginning of the input file (diff)
downloadgit-2e1dfd62dca9aecb0ec1bdf3d1927a8da6d95723.tar.gz
git-2e1dfd62dca9aecb0ec1bdf3d1927a8da6d95723.zip
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 'utf8.c')
-rw-r--r--utf8.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/utf8.c b/utf8.c
index 520fbb4994..28e6d76a42 100644
--- a/utf8.c
+++ b/utf8.c
@@ -633,3 +633,14 @@ int is_hfs_dotgit(const char *path)
return 1;
}
+
+const char utf8_bom[] = "\357\273\277";
+
+int skip_utf8_bom(char **text, size_t len)
+{
+ if (len < strlen(utf8_bom) ||
+ memcmp(*text, utf8_bom, strlen(utf8_bom)))
+ return 0;
+ *text += strlen(utf8_bom);
+ return 1;
+}