1

As the title says, I am trying to apply a patch to a file and it fails because the file has the UTF8 BOM, but the patch does not mention it.

How can I resolve around it without removing the UTF8 BOM from the file?

2
  • stackoverflow.com/questions/27223985/… ? Commented Nov 7, 2018 at 14:51
  • I do not mind showing it. I need it in the context of applying patches. Specifically, I do not want the presence of it to fail the patch. Commented Nov 7, 2018 at 14:52

2 Answers 2

1

I solved the problem by creating a whole-file patch (git diff -B). This patch could be applied. (Of course this works not for patches which you got from other places)

Sign up to request clarification or add additional context in comments.

Comments

0

The simplest solution is to remove it, perhaps temporarily (i.e., remove it, apply patch, put it back). Since git apply works by default on the work-tree contents, this should be easy enough and does not require making or deleting any commits.

Note that a UTF-8 BOM is technically useless, because UTF-8 has no byte-order issue in the first place. (Some software might use it to imply that the file is UTF-8 encoded, though.)

1 Comment

I ended up doing what you suggest - remove, apply, put it back. It is not my business to remove the BOM, if it is there. It is frustrating, though, that git does not know to handle it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.