summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-05-13 21:05:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-05-13 21:05:51 (GMT)
commit8a1d89745d1b60d0d9e8bd91e4e9564673b6c22a (patch)
treeeef6bd2437ba2a1188dbe1b4023b27ef99531b65 /config.c
parentebb464f0cba9efcb5552fad02f452f09f68fc9b2 (diff)
parent27547e5fccda134560ad0441aa5bfa187387cec0 (diff)
downloadgit-8a1d89745d1b60d0d9e8bd91e4e9564673b6c22a.zip
git-8a1d89745d1b60d0d9e8bd91e4e9564673b6c22a.tar.gz
git-8a1d89745d1b60d0d9e8bd91e4e9564673b6c22a.tar.bz2
Merge branch 'cn/bom-in-gitignore' into maint
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 'config.c')
-rw-r--r--config.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/config.c b/config.c
index 66c0a51..c4424c0 100644
--- a/config.c
+++ b/config.c
@@ -12,6 +12,7 @@
#include "quote.h"
#include "hashmap.h"
#include "string-list.h"
+#include "utf8.h"
struct config_source {
struct config_source *prev;
@@ -417,8 +418,7 @@ static int git_parse_source(config_fn_t fn, void *data)
struct strbuf *var = &cf->var;
/* U+FEFF Byte Order Mark in UTF8 */
- static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
- const unsigned char *bomptr = utf8_bom;
+ const char *bomptr = utf8_bom;
for (;;) {
int c = get_next_char();
@@ -426,7 +426,7 @@ static int git_parse_source(config_fn_t fn, void *data)
/* We are at the file beginning; skip UTF8-encoded BOM
* if present. Sane editors won't put this in on their
* own, but e.g. Windows Notepad will do it happily. */
- if ((unsigned char) c == *bomptr) {
+ if (c == (*bomptr & 0377)) {
bomptr++;
continue;
} else {