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

Re: [PATCH] dir: allow a BOM at the beginning of exclude files

From
Carlos Martín Nieto <cmn@elego.de>
Date
Apr 16, 2015, 15:09 UTC
Message-ID
<1429196958.3097.15.camel@elego.de>
In-Reply-To
<13f82e720ac12a6bc12e8b9f566dd48e@www.dscho.org>
On Thu, 2015-04-16 at 17:03 +0200, Johannes Schindelin wrote:
Show 27 quoted lines
> Hi Carlos,
> 
> On 2015-04-16 16:05, Carlos Martín Nieto wrote:
> > Some text editors like Notepad or LibreOffice write an UTF-8 BOM in
> > order to indicate that the file is Unicode text rather than whatever the
> > current locale would indicate.
> > 
> > If someone uses such an editor to edit a gitignore file, we are left
> > with those three bytes at the beginning of the file. If we do not skip
> > them, we will attempt to match a filename with the BOM as prefix, which
> > won't match the files the user is expecting.
> > 
> > ---
> > 
> > If you're wondering how I came up with LibreOffice, I was doing a
> > workshop recently and one of the participants was not content with the
> > choice of vim or nano, so he opened LibreOffice to edit the gitignore
> > file with confusing consequences.
> > 
> > This codepath doesn't go as far as the config code in validating that
> > we do not have a partial BOM which would mean there's some invalid
> > content, but we don't really have invalid content any other way, as
> > we're just dealing with a list of paths in the file.
> 
> Yeah, users are entertaining!
> 
> I agree that this is a good patch. *Maybe* we would need the same handling in more places, in which case it might make sense to refactor the test into its own function.

Yes, this was my train of thought. If we (discover that) need it in a third place, then we can unify the test and skip. For two places I reckoned it was fine if we duplicated a bit.

> 
> In any case, though, the Git project requires a [Developer's Certificate of Origin](https://github.com/git/git/blob/v2.3.5/Documentation/SubmittingPatches#L234-L277); Would you mind adding that?
> 

Yeah, sorry. I keep forgetting to do that. I'll reply to my original e-mail with it.

Cheers,
   cmn
Previous: Johannes SchindelinNext: Carlos Martín Nieto
Message 3 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.