git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Oakley <andrew@adoakley.name>
To: "Tao Klerks via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Tao Klerks <tao@klerks.biz>
Subject: Re: [PATCH v2] [RFC] git-p4: improve encoding handling to support inconsistent encodings
Date: Wed, 13 Apr 2022 21:41:09 +0100	[thread overview]
Message-ID: <20220413214109.48097ac1@ado-tr.dyn.home.arpa> (raw)
In-Reply-To: <pull.1206.v2.git.1649831069578.gitgitgadget@gmail.com>

Thanks for doing this.  I've been meaning to write some similar code
for years and never quite got around to it.  So maybe my opinion
shouldn't be worth much :/.

On Wed, 13 Apr 2022 06:24:29 +0000
"Tao Klerks via GitGitGadget" <gitgitgadget@gmail.com> wrote:
> Make the changelist-description- and user-fullname-handling code
> python-runtime-agnostic, introducing three "strategies" selectable via
> config:
> - 'legacy', behaving as previously under python2,
> - 'strict', behaving as previously under python3, and
> - 'fallback', favoring utf-8 but supporting a secondary encoding when
> utf-8 decoding fails, and finally replacing remaining unmappable
> bytes.

I was thinking about making the config option be a list of encodings to
try.  So the options you've given map something like this:
- "legacy" -> "raw"
- "strict" -> "utf8"
- "fallback" -> "utf8 cp1252" (or whatever is configured)

This doesn't handle the case of using a replacement character, but in
reality I suspect that fallback encoding will always be a legacy 8bit
codec anyway.

I think what you've proposed is fine too, I'm not sure what would end
up being easier to understand.

>      * Does it make sense to make "fallback" the default decoding
> strategy in python3? This is definitely a change in behavior, but I
> believe for the better; failing with "we defaulted to strict, but you
> can run again with this other option if you want it to work" seems
> unkind, only making sense if we thought fallback to cp1252 would be
> wrong in a substantial proportion of cases...

The only issue I can see with changing the default is that it might
lead to a surprising loss of data for someone migrating to git.  Maybe
print a warning the first time git-p4 encounters something that can't be
decoded as UTF-8, but then continue with the fallback to cp1252?

>      * Is it OK to duplicate the bulk of the testing code across
>        t9835-git-p4-metadata-encoding-python2.sh and
>        t9836-git-p4-metadata-encoding-python3.sh?
>      * Is it OK to explicitly call "git-p4.py" in tests, rather than
> the build output "git-p4", in order to be able to select the python
>        runtime on a per-test basis? Is there a better approach?

I tried to find a nicer way to do this and failed.

>      * Is the naming of the strategies appropriate? Should the default
>        python2 strategy be called something less opinionated, like
>        "passthrough"?

I think that "passthrough" or "raw" would be more descriptive names.

The changes to git-p4 itself look good to me.  I think that dealing
with bytes more and strings less will be good going forward.

  parent reply	other threads:[~2022-04-13 21:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11  9:42 [PATCH] [RFC] git-p4: improve encoding handling to support inconsistent encodings Tao Klerks via GitGitGadget
2022-04-13  6:24 ` [PATCH v2] " Tao Klerks via GitGitGadget
2022-04-13 13:59   ` Ævar Arnfjörð Bjarmason
2022-04-13 15:18     ` Tao Klerks
2022-04-13 18:52       ` Ævar Arnfjörð Bjarmason
2022-04-14  9:38         ` Tao Klerks
2022-04-13 20:41   ` Andrew Oakley [this message]
2022-04-14  9:57     ` Tao Klerks
2022-04-17 18:11       ` Andrew Oakley
2022-04-19 20:30         ` Tao Klerks
2022-04-19 20:19   ` [PATCH v3] " Tao Klerks via GitGitGadget
2022-04-19 20:33     ` Tao Klerks
2022-04-30 19:26     ` [PATCH v4] " Tao Klerks via GitGitGadget

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=20220413214109.48097ac1@ado-tr.dyn.home.arpa \
    --to=andrew@adoakley.name \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=tao@klerks.biz \
    /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).