Re: [PATCH v2 3/3] shorten_unambiguous_ref(): avoid sscanf()
- From
Torsten Bögershausen <tboegi@web.de>
- Date
- Feb 16, 2023, 05:56 UTC
- Message-ID
- <20230216055641.brlx3os2ucj3ywer@tb-raspi4>
- In-Reply-To
- <Y+z3RfhAxW/2iNYP@coredump.intra.peff.net>
On Wed, Feb 15, 2023 at 10:16:21AM -0500, Jeff King wrote: []
Show 13 quoted lines
> +test_expect_success 'symbolic-ref --short handles complex utf8 case' ' > + name="测试-加-增加-加-增加" && > + git symbolic-ref TEST_SYMREF "refs/heads/$name" && > + # In the real world, we saw problems with this case only > + # when the locale includes UTF-8. Set it here to try to make things as > + # hard as possible for us to pass, but in practice we should do the > + # right thing regardless (and of course some platforms may not even > + # have this locale). > + LC_ALL=en_US.UTF-8 git symbolic-ref --short TEST_SYMREF >actual && > + echo "$name" >expect && > + test_cmp expect actual > +' > +
Hm, I may have 1 or two questions here. The real world was MacOs, should that be mentioned here?
The other thing seems to be that there is a bug even with LANG=C, see the response from Eric here:
$ git symbolic-ref --short HEAD | xxd 00000000: e6b5 8be8 af95 2de5 8a0a ......-... $ LANG=C git symbolic-ref --short HEAD | xxd 00000000: e6b5 8be8 af95 2de5 8aa0 2de5 a29e e58a ......-...-..... 00000010: a02d e58a a02d e5a2 9ee5 8aa0 0a .-...-.......
Does it make sense to a) Use the local locale, what ever that is b) Re-run with LC_ALL=en_US.UTF-8 c) Re-run with LANG=C (that is where I had suspected problems when using UTF-8) d) Mention MacOs here ?
Somewhat in that style:
test_expect_success 'symbolic-ref --short handles complex utf8 case' ' name="测试-加-增加-加-增加" && git symbolic-ref TEST_SYMREF "refs/heads/$name" && # In the real world, we saw problems with this case only under MacOs Ventura # when the locale includes UTF-8. Try it here to try to make things as # hard as possible for us to pass, but in practice we should do the # right thing regardless (and of course some platforms may not even # have this locale). # Use try even the default and LANG=C git symbolic-ref --short TEST_SYMREF >actual && echo "$name" >expect && test_cmp expect actual && LC_ALL=en_US.UTF-8 git symbolic-ref --short TEST_SYMREF >actual && echo "$name" >expect && test_cmp expect actual && LANG=C git symbolic-ref --short TEST_SYMREF >actual && echo "$name" >expect && test_cmp expect actual '