Git diff algorithm

200 views
Skip to first unread message

Balázs Bayer

unread,
Oct 24, 2019, 4:25:21 AM10/24/19
to Repo and Gerrit Discussion
Hi all,

which diff algorithm is used by Gerrit by default, where can I change it, and if possible, which algorithms can be selected?

The documentation mentions the JGIT related config here: :https://gerrit-review.googlesource.com/Documentation/config-gerrit.html#jgitConfig

But it does not go into the details.

Gerrit version: 2.16.3

Thanks in advance,
Balázs


Balázs Bayer

unread,
Oct 24, 2019, 5:22:47 AM10/24/19
to Repo and Gerrit Discussion
and also: can we set this up on project level?

Matthias Sohn

unread,
Oct 24, 2019, 8:07:01 AM10/24/19
to Balázs Bayer, Repo and Gerrit Discussion
see https://git-scm.com/docs/git-config#Documentation/git-config.txt-diffalgorithm for the configuration option "diff.algorithm"

JGit supports the algorithms "myers" and "histogram" and uses "histogram" as the default since it's faster and typically
creates nicer diffs for real world source files [1].


-Matthias

David Ostrovsky

unread,
Oct 24, 2019, 8:30:51 AM10/24/19
to Repo and Gerrit Discussion

Am Donnerstag, 24. Oktober 2019 14:07:01 UTC+2 schrieb Matthias Sohn:
On Thu, Oct 24, 2019 at 10:25 AM Balázs Bayer <balaz...@gmail.com> wrote:
Hi all,

which diff algorithm is used by Gerrit by default, where can I change it, and if possible, which algorithms can be selected?

The documentation mentions the JGIT related config here: :https://gerrit-review.googlesource.com/Documentation/config-gerrit.html#jgitConfig

But it does not go into the details.

Gerrit version: 2.16.3

see https://git-scm.com/docs/git-config#Documentation/git-config.txt-diffalgorithm for the configuration option "diff.algorithm"

JGit supports the algorithms "myers" and "histogram" and uses "histogram" as the default since it's faster and typically
creates nicer diffs for real world source files [1].

We have also seen issues with Myers diff implementation in the wild. That why the code
is somehow convoluted, and starts diffing with whatever algorithm is configured on JGit
side, but then interrupts the computation after configurable timeout (default 5 seconds),
and re-computes the diff with hard coded histogram diff algorithm, see: [2].


Reply all
Reply to author
Forward
0 new messages