Commit 133bceba by Edward Thomson

ignore: skip UTF8 BOM in ignore file

parent 73a157e0
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "repository.h" #include "repository.h"
#include "filebuf.h" #include "filebuf.h"
#include "attrcache.h" #include "attrcache.h"
#include "buf_text.h"
#include "git2/blob.h" #include "git2/blob.h"
#include "git2/tree.h" #include "git2/tree.h"
#include "blob.h" #include "blob.h"
...@@ -108,9 +109,12 @@ int git_attr_file__load( ...@@ -108,9 +109,12 @@ int git_attr_file__load(
int error = 0; int error = 0;
git_blob *blob = NULL; git_blob *blob = NULL;
git_buf content = GIT_BUF_INIT; git_buf content = GIT_BUF_INIT;
const char *content_str;
git_attr_file *file; git_attr_file *file;
struct stat st; struct stat st;
bool nonexistent = false; bool nonexistent = false;
int bom_offset;
git_bom_t bom;
*out = NULL; *out = NULL;
...@@ -159,13 +163,20 @@ int git_attr_file__load( ...@@ -159,13 +163,20 @@ int git_attr_file__load(
if ((error = git_attr_file__new(&file, entry, source)) < 0) if ((error = git_attr_file__new(&file, entry, source)) < 0)
goto cleanup; goto cleanup;
/* advance over a UTF8 BOM */
content_str = git_buf_cstr(&content);
bom_offset = git_buf_text_detect_bom(&bom, &content);
if (bom == GIT_BOM_UTF8)
content_str += bom_offset;
/* store the key of the attr_reader; don't bother with cache /* store the key of the attr_reader; don't bother with cache
* invalidation during the same attr reader session. * invalidation during the same attr reader session.
*/ */
if (attr_session) if (attr_session)
file->session_key = attr_session->key; file->session_key = attr_session->key;
if (parser && (error = parser(repo, file, git_buf_cstr(&content))) < 0) { if (parser && (error = parser(repo, file, content_str)) < 0) {
git_attr_file__free(file); git_attr_file__free(file);
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment