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

Re: [PATCH] git-p4: add "--path-encoding" option

From
Torsten Bögershausen <tboegi@web.de>
Date
Aug 31, 2015, 19:22 UTC
Message-ID
<55E4A965.8040305@web.de>
In-Reply-To
<xmqqpp23we4d.fsf@gitster.mtv.corp.google.com>
On 2015-08-31 19.40, Junio C Hamano wrote:
> larsxschneider@gmail.com writes:
Show 19 quoted lines
>> +test_expect_success 'Create a repo containing cp1251 encoded paths' '
>> +	cd "$cli" &&
>> +
>> +	FILENAME="$(echo "a-¤_o-¶_u-¼.txt" | iconv -f utf-8 -t cp1252)" &&
> 
> Hmm, we'd be better off not having a bare UTF-8 sequence in the
> source like this, especially when you already have the same thing
> backslash-escaped in the "expect" file below.  Perhaps
> 
> 	NAME="a-\303\244_o-\303\266_u-\303\274.txt" &&
> 
> 	UTF8=$(printf "$NAME") &&
>         CP1252=$(printf "$NAME" | iconv -t cp1252) &&
>         echo "\"$UTF8\"" >expect &&
> 
>         >"$CP1252" &&
>         p4 add "$CP1252" &&
>         ...
> 
Using file names and iconv like this may not be portable:
- cp1252 may be called CP1252 (or may not be available)
- reading from stdin is not necessarily supported by iconv
- creating files in CP1252 may not be supported under Mac OS
   (Not sure about Windows)

One solution could be to use ISO-8859-1, convert into UTF-8, and "convert into UTF-8" one more time.

We can skip using iconv in the test case completely, and use something like this: (Fully untested)

UTF8=$(printf '\303\203\302\204') NAME=$(printf '\303\204')

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 5 in “git-p4: add "--path-encoding" option”
  1. git-p4: add "--path-encoding" optionlarsxschneider@gmail.com, Aug 31, 2015
  2. git-p4: add "--path-encoding" optionlarsxschneider@gmail.com, Aug 31, 2015
  3. Junio C HamanoAug 31, 2015
  4. Torsten BögershausenAug 31, 2015
  5. Junio C HamanoAug 31, 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.