mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-11-23 21:54:45 +02:00
ignore/gitignore: skip BOM at start of ignore file
This matches Git's behavior. Fixes #2177, Closes #2782
This commit is contained in:
committed by
Andrew Gallant
parent
c93fc793a0
commit
483628469a
@@ -402,6 +402,12 @@ impl GitignoreBuilder {
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// Match Git's handling of .gitignore files that begin with the Unicode BOM
|
||||
const UTF8_BOM: &str = "\u{feff}";
|
||||
let line =
|
||||
if i == 0 { line.trim_start_matches(UTF8_BOM) } else { &line };
|
||||
|
||||
if let Err(err) = self.add_line(Some(path.to_path_buf()), &line) {
|
||||
errs.push(err.tagged(path, lineno));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user