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

Re: [PATCH v7] git-p4: improve path encoding verbose output

From
Luke Diamand <luke@diamand.org>
Date
Sep 15, 2015, 07:31 UTC
Message-ID
<55F7C93D.1080309@diamand.org>
In-Reply-To
<1442250640-93838-2-git-send-email-larsxschneider@gmail.com>
On 14/09/15 18:10, larsxschneider@gmail.com wrote:
> From: Lars Schneider <larsxschneider@gmail.com>
>
> If a path with non-ASCII characters is detected then print always the
s/print always/print/
Show 31 quoted lines
> encoding and the encoded string in verbose mode.
>
> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
> ---
>   git-p4.py | 19 +++++++++----------
>   1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index d45cf2b..da25d3f 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -2220,16 +2220,15 @@ class P4Sync(Command, P4UserMap):
>               text = regexp.sub(r'$\1$', text)
>               contents = [ text ]
>
> -        if gitConfig("git-p4.pathEncoding"):
> -            relPath = relPath.decode(gitConfig("git-p4.pathEncoding")).encode('utf8', 'replace')
> -        elif self.verbose:
> -            try:
> -                relPath.decode('ascii')
> -            except:
> -                print (
> -                    "Path with Non-ASCII characters detected and no path encoding defined. "
> -                    "Please check the encoding: %s" % relPath
> -                )
> +        try:
> +            relPath.decode('ascii')
> +        except:
> +            encoding = 'utf8'
> +            if gitConfig('git-p4.pathEncoding'):
> +                encoding = gitConfig('git-p4.pathEncoding')

It would be better to query this once at startup. Otherwise we're potentially forking "git config" twice per file which on a large repo could become significant. Make it an instance variable perhaps?

Show 7 quoted lines
> +                relPath = relPath.decode(encoding).encode('utf8', 'replace')
> +            if self.verbose:
> +                print 'Path with non-ASCII characters detected. Used %s to encode: %s ' % (encoding, relPath)
>
>           self.gitStream.write("M %s inline %s\n" % (git_mode, relPath))
>
>
Previous: Lars SchneiderNext: Luke Diamand
Message 5 of 8 in “git-p4: add config git-p4.pathEncoding”
  1. git-p4: add config git-p4.pathEncodinglarsxschneider@gmail.com, Sep 14, 2015
  2. git-p4: improve path encoding verbose outputlarsxschneider@gmail.com, Sep 14, 2015
  3. Junio C HamanoSep 14, 2015
  4. Lars SchneiderSep 15, 2015
  5. Luke DiamandSep 15, 2015
  6. Luke DiamandSep 15, 2015
  7. Lars SchneiderSep 15, 2015
  8. Junio C HamanoSep 14, 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.