git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Oakley <andrew@adoakley.name>
To: "Feiyang via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Feiyang <github@feiyangxue.com>,
	Feiynag Xue <fxue@roku.com>
Subject: Re: [PATCH] git-p4: handle non-unicode characters in p4 cl
Date: Thu, 4 Feb 2021 18:45:34 +0000	[thread overview]
Message-ID: <20210204184534.30107dd7@ado-tr.home.arpa> (raw)
In-Reply-To: <pull.864.git.1612371600332.gitgitgadget@gmail.com>

On Wed, 03 Feb 2021 16:59:59 +0000
"Feiyang via GitGitGadget" <gitgitgadget@gmail.com> wrote:
> From: Feiynag Xue <fxue@roku.com>
> 
> P4 allows non-unicode characters in changelist description body,
> so git-p4 needs to be character encoding aware when reading p4 cl
> 
> This change adds 2 config options, one specifies encoding,
> the other specifies erro handling upon unrecognized character.
> Those configs  apply when it reads p4 description text, mostly
> from commands "p4 describe" and "p4 changes".

...

>     It seems to make sense to default to replace so that it gets rid
> of non-unicode chars while trying to retain information. However, i am
>     uncertain on if we have use cases where it relies on the
>     stop-on-non-unicode behavior. (Hypothetically say an automation
> that's expected to return error on non-unicode char in order to stop
> them from propagating further?)

I suspect these options will be insufficient for real repositories.

There are two ways a perforce server is configured:
- unicode mode where the metadata is valid UTF-8, and you can request
  conversion to different character sets
- not in unicode mode where the metadata can be pretty much any random
  bytes (but not '\0'), and the encoding is not stored anywhere

There isn't any way to recover the encoding information from perforce,
and it's likely that a server that's not in unicode mode will end up
with both UTF-8 commits, and commits that contain other things (which
we have no way to work out what they are).

Until recently git-p4 was written in python2 and it just moved the
bytes from perforce into git without trying to interpret them in any
way.  This has the advantage that the git repository will accurately
reflect what was in perforce, even if it's complete garbage.

The other useful option I can think of would be to attempt to decode
the data as UTF-8, but fall back to some other encoding if the data
isn't valid (probably Windows-1252, but a config option would make
sense here).

      parent reply	other threads:[~2021-02-04 19:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-03 16:59 [PATCH] git-p4: handle non-unicode characters in p4 cl Feiyang via GitGitGadget
2021-02-03 21:44 ` Junio C Hamano
     [not found]   ` <BD039BE8-643F-4F61-A0DB-E3581C6B6B10@feiyangxue.com>
2021-02-04  0:11     ` Luke Diamand
2021-02-04 18:45 ` Andrew Oakley [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210204184534.30107dd7@ado-tr.home.arpa \
    --to=andrew@adoakley.name \
    --cc=fxue@roku.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=github@feiyangxue.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).