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

Re: [PATCH v8 7/7] convert: add round trip check based on 'core.checkRoundtripEncoding'

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 4, 2018, 19:58 UTC
Message-ID
<CAPig+cR1zEn0ktDtQnUt2272gZ04S-Ssg7Vzja6QZejTLN_fbQ@mail.gmail.com>
In-Reply-To
<5955B68D-B6E3-43C0-8C70-47E37F1204E1@gmail.com>
On Sun, Mar 4, 2018 at 2:08 PM, Lars Schneider <larsxschneider@gmail.com> wrote:
Show 12 quoted lines
>> On 25 Feb 2018, at 20:50, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Sat, Feb 24, 2018 at 11:28 AM,  <lars.schneider@autodesk.com> wrote:
>>> +               if (!re_src || src_len != re_src_len ||
>>> +                   memcmp(src, re_src, src_len)) {
>>> +                       const char* msg = _("encoding '%s' from %s to %s and "
>>> +                                           "back is not the same");
>>> +                       die(msg, path, enc->name, default_encoding);
>>
>> Last two arguments need to be swapped.
>
> Hm. Are you sure? I think it is correct as it is. We are in encode_to_git()
> here and that means we encode *to* "default encoding", no?

Okay. I guess I was just looking at the most recent reencode_string_len() -- and maybe overlooked the "and back" -- and was thinking that this error message applied directly to it, but I see your point about the error saying something about encode_to_git() overall, in which case I agree with you.

Show 13 quoted lines
>>> +       test_config core.checkRoundtripEncoding "garbage" &&
>>> +       ! GIT_TRACE=1 git add .gitattributes roundtrip.shift 2>&1 >/dev/null |
>>> +               grep "Checking roundtrip encoding for SHIFT-JIS" &&
>>> +       test_unconfig core.checkRoundtripEncoding &&
>>
>> The "unconfig" won't take place if the test fails. Instead of
>> test_config/test_unconfig, you could use '-c' to set the config
>> transiently for the git-add operation:
>>
>>    ! GIT_TRACE=1 git -c core.checkRoundtripEncoding=garbage add ...
>
> Agreed. Although test_config (in t/test-lib-functions.sh) automatically
> unsets itself after the test is over.

Yep, so you could get by with that alone. The test_unconfig() simply isn't needed.

Previous: Lars Schneider
Message 20 of 20 in “convert: add support for different encodings”
  1. 0/7 convert: add support for different encodingslars.schneider@autodesk.com, Feb 24, 2018
  2. 1/7 strbuf: remove unnecessary NUL assignment in xstrdup_tolower()lars.schneider@autodesk.com, Feb 24, 2018
  3. 2/7 strbuf: add xstrdup_toupper()lars.schneider@autodesk.com, Feb 24, 2018
  4. 3/7 utf8: add function to detect prohibited UTF-16/32 BOMlars.schneider@autodesk.com, Feb 24, 2018
  5. Eric SunshineFeb 25, 2018
  6. Lars SchneiderFeb 25, 2018
  7. Eric SunshineFeb 27, 2018
  8. Lars SchneiderFeb 28, 2018
  9. 5/7 convert: add 'working-tree-encoding' attributelars.schneider@autodesk.com, Feb 24, 2018
  10. Eric SunshineFeb 25, 2018
  11. Lars SchneiderFeb 27, 2018
  12. Eric SunshineFeb 28, 2018
  13. 6/7 convert: add tracing for 'working-tree-encoding' attributelars.schneider@autodesk.com, Feb 24, 2018
  14. 4/7 utf8: add function to detect a missing UTF-16/32 BOMlars.schneider@autodesk.com, Feb 24, 2018
  15. Eric SunshineFeb 25, 2018
  16. Lars SchneiderFeb 25, 2018
  17. 7/7 convert: add round trip check based on 'core.checkRoundtripEncoding'lars.schneider@autodesk.com, Feb 24, 2018
  18. Eric SunshineFeb 25, 2018
  19. Lars SchneiderMar 4, 2018
  20. Eric SunshineMar 4, 2018

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.