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, 18:27 UTC
Message-ID
<1429208863.3097.19.camel@elego.de>
In-Reply-To
<xmqqoamohu2m.fsf@gitster.dls.corp.google.com>
On Thu, 2015-04-16 at 10:16 -0700, Junio C Hamano wrote:
Show 64 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > On Thu, Apr 16, 2015 at 08:39:55AM -0700, Junio C Hamano wrote:
> >
> >> >  test_expect_success 'status untracked directory with --ignored' '
> >> >  	echo "ignored" >.gitignore &&
> >> > +	sed -e "s/^/\xef\xbb\xbf/" .gitignore >.gitignore.new &&
> >> > +	mv .gitignore.new .gitignore &&
> >> 
> >> Is this "write literal in \xHEX on the replacement side of sed
> >> substitution" potable?  In any case, replacing the above three with
> >> something like:
> >> 
> >> 	printf "<bom>ignored\n" >.gitignore
> >> 
> >> may be more sensible, no?
> >
> > I'm not sure about sed, but I agree it is suspect. And note that printf
> > with hex codes is not portable, either You have to use octal:
> >
> >   printf '\357\273\277ignored\n' >.gitignore
> >
> > Also, as a nit, I'd much rather see this in its own test rather than
> > crammed into another test_expect_success. It's much easier to diagnose
> > failures if the test description mentions the goal, and it is not tied
> > up with testing other parts that might fail.
> 
> Yeah, I totally agree.
> 
> Carlos, something like this squashed in, perhaps?
> 
>  t/t7061-wtstatus-ignore.sh | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/t/t7061-wtstatus-ignore.sh b/t/t7061-wtstatus-ignore.sh
> index 0a06fbf..cdc0747 100755
> --- a/t/t7061-wtstatus-ignore.sh
> +++ b/t/t7061-wtstatus-ignore.sh
> @@ -13,8 +13,6 @@ EOF
>  
>  test_expect_success 'status untracked directory with --ignored' '
>  	echo "ignored" >.gitignore &&
> -	sed -e "s/^/\xef\xbb\xbf/" .gitignore >.gitignore.new &&
> -	mv .gitignore.new .gitignore &&
>  	mkdir untracked &&
>  	: >untracked/ignored &&
>  	: >untracked/uncommitted &&
> @@ -22,6 +20,15 @@ test_expect_success 'status untracked directory with --ignored' '
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'same with gitignore starting with BOM' '
> +	printf "\357\273\277ignored\n" >.gitignore &&
> +	mkdir -p untracked &&
> +	: >untracked/ignored &&
> +	: >untracked/uncommitted &&
> +	git status --porcelain --ignored >actual &&
> +	test_cmp expected actual
> +'
> +
>  cat >expected <<\EOF
>  ?? .gitignore
>  ?? actual
> 

Yeah, that makes sense. I had something similar in my patch at one point before going with modifying the current one.

   cmn
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 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.