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

Re: [PATCH v10 6/9] convert: add 'working-tree-encoding' attribute

From
Lars Schneider <larsxschneider@gmail.com>
Date
Mar 7, 2018, 22:56 UTC
Message-ID
<66370A41-A048-44E7-9BF8-4631C50AAE63@gmail.com>
In-Reply-To
<CAPig+cSvC1a5EaDfFZdJU74mZz84M=CkeOJLSDxFdXKcJYyzEw@mail.gmail.com>
Show 32 quoted lines
> On 07 Mar 2018, at 18:54, Eric Sunshine <sunshine@sunshineco.com> wrote:
> 
> On Wed, Mar 7, 2018 at 12:30 PM,  <lars.schneider@autodesk.com> wrote:
>> [...]
>> Add an attribute to tell Git what encoding the user has defined for a
>> given file. If the content is added to the index, then Git converts the
>> content to a canonical UTF-8 representation. On checkout Git will
>> reverse the conversion.
>> 
>> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
>> ---
>> Documentation/gitattributes.txt  |  80 +++++++++++++++++++++++
>> diff --git a/convert.c b/convert.c
>> @@ -265,6 +266,78 @@ static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats,
>> +static const char *default_encoding = "UTF-8";
>> @@ -978,6 +1051,21 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
>> +static const char *git_path_check_encoding(struct attr_check_item *check)
>> +{
>> +       const char *value = check->value;
>> +
>> +       if (ATTR_TRUE(value) || ATTR_FALSE(value) || ATTR_UNSET(value) ||
>> +           !strlen(value))
>> +               return NULL;
>> +
>> +       /* Don't encode to the default encoding */
>> +       if (!strcasecmp(value, default_encoding))
>> +               return NULL;
> 
> As of v10, the rest of the code accepts encoding names "UTF-xx" and
> "UTFxx" (case insensitive), however, this check recognizes only
> "UTF-8" (case insensitive). For consistency, one would expect this
> also to recognize "UTF8" (case insensitive).
Nice catch. What do you think about this solution using is_encoding_utf8()
from utf.c?
	
	if (is_encoding_utf8(value) && is_encoding_utf8(default_encoding)) 
- Lars
Previous: Eric SunshineNext: Junio C Hamano
Message 14 of 32 in “convert: add support for different encodings”
  1. 0/9 convert: add support for different encodingslars.schneider@autodesk.com, Mar 7, 2018
  2. 1/9 strbuf: remove unnecessary NUL assignment in xstrdup_tolower()lars.schneider@autodesk.com, Mar 7, 2018
  3. 2/9 strbuf: add xstrdup_toupper()lars.schneider@autodesk.com, Mar 7, 2018
  4. 3/9 strbuf: add a case insensitive starts_with()lars.schneider@autodesk.com, Mar 7, 2018
  5. Duy NguyenMar 8, 2018
  6. Junio C HamanoMar 8, 2018
  7. Lars SchneiderMar 9, 2018
  8. Junio C HamanoMar 9, 2018
  9. Ævar Arnfjörð BjarmasonMar 9, 2018
  10. 4/9 utf8: add function to detect prohibited UTF-16/32 BOMlars.schneider@autodesk.com, Mar 7, 2018
  11. 5/9 utf8: add function to detect a missing UTF-16/32 BOMlars.schneider@autodesk.com, Mar 7, 2018
  12. 6/9 convert: add 'working-tree-encoding' attributelars.schneider@autodesk.com, Mar 7, 2018
  13. Eric SunshineMar 7, 2018
  14. Lars SchneiderMar 7, 2018
  15. Junio C HamanoMar 7, 2018
  16. Junio C HamanoMar 7, 2018
  17. 7/9 convert: check for detectable errors in UTF encodingslars.schneider@autodesk.com, Mar 7, 2018
  18. Eric SunshineMar 7, 2018
  19. Lars SchneiderMar 9, 2018
  20. Junio C HamanoMar 7, 2018
  21. Lars SchneiderMar 7, 2018
  22. Junio C HamanoMar 7, 2018
  23. Lars SchneiderMar 7, 2018
  24. Junio C HamanoMar 7, 2018
  25. Lars SchneiderMar 7, 2018
  26. Junio C HamanoMar 7, 2018
  27. 9/9 convert: add round trip check based on 'core.checkRoundtripEncoding'lars.schneider@autodesk.com, Mar 7, 2018
  28. Junio C HamanoMar 7, 2018
  29. Lars SchneiderMar 7, 2018
  30. Junio C HamanoMar 7, 2018
  31. Lars SchneiderMar 7, 2018
  32. 8/9 convert: add tracing for 'working-tree-encoding' attributelars.schneider@autodesk.com, Mar 7, 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.