From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Ping Yin <pkufranky@gmail.com>
Cc: mailinggit list <git@vger.kernel.org>
Subject: Re: [bug] git diff --word-diff gives wrong result for utf-8 chinese
Date: Tue, 29 Nov 2022 11:52:38 +0100 [thread overview]
Message-ID: <221129.867czejabi.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <CACSwcnQfTOYHxSJQqc+viiqkCqt=WZieuCw70PqOdvo88XdeOQ@mail.gmail.com>
On Tue, Nov 29 2022, Ping Yin wrote:
> Result of "git diff"
>
> - 为1
> + 为2
>
> or (if chinese can not be displayed correctly)
>
> - <E4><B8><BA>1
> + <E4><B8><BA>2
>
> Actual result of "git diff --color-words"
>
> <E4><B8>[-<BA>1-]{+<BA>2+}
>
> Expected result of "git diff --color-words"
>
> 为[-1-]{+2+}
>
> or (if chinese can not be displayed correctly)
I think we could provide new ways to do per-language diffs, right now
you can use --word-diff-regex, but it would be handy to e.g. have a
built-in collection of those (or other non-regex boundary algorithms)
for Chinese etc.
But as for considering this a bug, or changing the existing behavior I
think we'd need to deal with:
* We (approximately) split on space now, which is certainly
ASCII-biased, and outside of CJK fairly somewhat universal.
* If we're going to split on "real words" in some cross-language aware
way, are we going to run into conflicts between what different
languages would consider sensible rules?
* We probably don't want to make the "diff" dependent on the user's
locale, but e.g. saying "I want a Chinese diff" via a CLI option
would be OK.
* Even for say Chinese, there's probably interesting edge cases when
it's combined with other languages or character sets (e.g. Chinese +
HTML).
next prev parent reply other threads:[~2022-11-29 10:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-29 3:46 [bug] git diff --word-diff gives wrong result for utf-8 chinese Ping Yin
2022-11-29 3:49 ` Ping Yin
2022-11-29 8:18 ` Bagas Sanjaya
2022-11-29 10:52 ` Ævar Arnfjörð Bjarmason [this message]
2022-11-29 11:32 ` Junio C Hamano
2022-11-29 18:23 ` Jeff King
2022-11-29 18:54 ` Jeff King
2022-12-01 7:08 ` Ping Yin
2022-12-01 7:33 ` Ping Yin
2022-12-01 14:51 ` Phillip Wood
2022-12-01 15:51 ` Ping Yin
2022-12-01 20:06 ` Jeff King
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=221129.867czejabi.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=pkufranky@gmail.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).