git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 0/4] UTF8 BOM follow-up

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 20, 2015, 21:50 UTC
Message-ID
<xmqqegnejwq7.fsf@gitster.dls.corp.google.com>
In-Reply-To
<55318CE2.1000706@gmail.com>
Karsten Blees <karsten.blees@gmail.com> writes:
> Wouldn't it be better to just strip the BOM on commit, e.g. via a
> clean filter or pre-commit hook (as suggested in [1])?

The users can do whatever they want and if they think having a BOM in these files is a bad idea, I'd encourage them to use whatever means to ensure that. The code and history hygiene is a good thing.

But you should realize that $HOME/.gitconfig, $GIT_DIR/info/exclude, $GIT_DIR/config, etc. are not even committed files in the first place. These are not even defined to be "UTF-8 only" by us. Their contents is entirely up to the end users.

Here with these changes, we are only being nice to the users by stripping a well-known two-byte sequence that is known to be left commonly by some tools users would use. In a sense, this is the same degree of niceness that we strip the CR at the end of the line before LF. Just like you _could_ have said these files must be encoded in UTF-8 and must not have BOM at the beginning, we _could_ have defined that these files must be recorded with LF end-of-line. But obviously we don't, as there is no need to make lives of end users unnecessarily more complex, and it is easy to help users use both LF and CRLF with simply stripping on our reader's side. We do this BOM stripping for the same reason to make it easier for users.

Previous: Karsten BleesNext: Johannes Schindelin
Message 22 of 24 in “dir: allow a BOM at the beginning of exclude files”
  1. dir: allow a BOM at the beginning of exclude filesCarlos Martín Nieto, Apr 16, 2015
  2. Johannes SchindelinApr 16, 2015
  3. Carlos Martín NietoApr 16, 2015
  4. Carlos Martín NietoApr 16, 2015
  5. Junio C HamanoApr 16, 2015
  6. Jeff KingApr 16, 2015
  7. Junio C HamanoApr 16, 2015
  8. 0/3 UTF8 BOM follow-upJunio C Hamano, Apr 16, 2015
  9. 1/3 utf8-bom: introduce skip_utf8_bom() helperJunio C Hamano, Apr 16, 2015
  10. Jeff KingApr 16, 2015
  11. Junio C HamanoApr 16, 2015
  12. 2/3 config: use utf8_bom[] from utf.[ch] in git_parse_source()Junio C Hamano, Apr 16, 2015
  13. 3/3 attr: skip UTF8 BOM at the beginning of the input fileJunio C Hamano, Apr 16, 2015
  14. Carlos Martín NietoApr 16, 2015
  15. 0/4 UTF8 BOM follow-upJunio C Hamano, Apr 16, 2015
  16. 1/4 add_excludes_from_file: clarify the bom skipping logicJunio C Hamano, Apr 16, 2015
  17. 2/4 utf8-bom: introduce skip_utf8_bom() helperJunio C Hamano, Apr 16, 2015
  18. 3/4 config: use utf8_bom[] from utf.[ch] in git_parse_source()Junio C Hamano, Apr 16, 2015
  19. 4/4 attr: skip UTF8 BOM at the beginning of the input fileJunio C Hamano, Apr 16, 2015
  20. Jeff KingApr 16, 2015
  21. Karsten BleesApr 17, 2015
  22. Junio C HamanoApr 20, 2015
  23. Johannes SchindelinApr 16, 2015
  24. Torsten BögershausenApr 16, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.