# v2.11 new diff heuristic?

4 messages from 2016-11-22 to 2016-11-22. Participants: Robert Dailey, Jacob Keller, Stefan Beller, Jeff King.
Thread: https://gitlist.dev/t/44530

## Robert Dailey, 2016-11-22 14:42

Subject: v2.11 new diff heuristic?
Message-ID: <CAHd499AjXh1YnVgBj_8j0fgvOgOn53y+sPBBy6y7mSM-+dCyVw@mail.gmail.com>
URL: https://gitlist.dev/e/CAHd499AjXh1YnVgBj_8j0fgvOgOn53y%2BsPBBy6y7mSM-%2BdCyVw%40mail.gmail.com

```
The release notes mention a new heuristic for diff:

* Output from "git diff" can be made easier to read by selecting
which lines are common and which lines are added/deleted
intelligently when the lines before and after the changed section
are the same. A command line option is added to help with the
experiment to find a good heuristics.

However, it lacks information on exactly how to use this new feature.
I dug into the git diff documentation here:

https://git-scm.com/docs/git-diff

It mentions a "--compaction-heuristic" option. Is this the new
heuristic outlined by the release notes? If not, which is it? Is the
compaction heuristic compatible with the histogram diff algorithm? Is
there a config option to turn this on all the time? For that matter,
is this something I can keep on all the time or is it only useful in
certain situations?

There's still so much more about this feature I would like to know.

```

## Jacob Keller, 2016-11-22 17:18

Subject: Re: v2.11 new diff heuristic?
Message-ID: <502984B2-1ADF-4BEC-9C5D-057AADAA7C61@gmail.com>
URL: https://gitlist.dev/e/502984B2-1ADF-4BEC-9C5D-057AADAA7C61%40gmail.com
In-Reply-To: <CAHd499AjXh1YnVgBj_8j0fgvOgOn53y+sPBBy6y7mSM-+dCyVw@mail.gmail.com>

```
On November 22, 2016 6:42:36 AM PST, Robert Dailey <rcdailey.lists@gmail.com> wrote:
>The release notes mention a new heuristic for diff:
>
>* Output from "git diff" can be made easier to read by selecting
>which lines are common and which lines are added/deleted
>intelligently when the lines before and after the changed section
>are the same. A command line option is added to help with the
>experiment to find a good heuristics.
>
>However, it lacks information on exactly how to use this new feature.
>I dug into the git diff documentation here:
>
>https://git-scm.com/docs/git-diff
>
>It mentions a "--compaction-heuristic" option. Is this the new
>heuristic outlined by the release notes? If not, which is it? Is the
>compaction heuristic compatible with the histogram diff algorithm? Is
>there a config option to turn this on all the time? For that matter,
>is this something I can keep on all the time or is it only useful in
>certain situations?
>
>There's still so much more about this feature I would like to know.

Hi,

Yes for now the compaction heuristic option has an undocumented config. (I forget the exact name off the top of my head). Currently it is being evaluated and likely we want to make it default in the near future once we are certain that it helps and doesn't make any difference worse.

So long term you will not need any special knobs to benefit.

Thanks,
Jake


```

## Stefan Beller, 2016-11-22 17:51

Subject: Re: v2.11 new diff heuristic?
Message-ID: <CAGZ79kbJ1vM=wd+53RezKEuucBCG96rL7dNhZpqR6m+brRAJ=w@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kbJ1vM%3Dwd%2B53RezKEuucBCG96rL7dNhZpqR6m%2BbrRAJ%3Dw%40mail.gmail.com
In-Reply-To: <CAHd499AjXh1YnVgBj_8j0fgvOgOn53y+sPBBy6y7mSM-+dCyVw@mail.gmail.com>

```
On Tue, Nov 22, 2016 at 6:42 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:
> The release notes mention a new heuristic for diff:
>
> * Output from "git diff" can be made easier to read by selecting
> which lines are common and which lines are added/deleted
> intelligently when the lines before and after the changed section
> are the same. A command line option is added to help with the
> experiment to find a good heuristics.
>
> However, it lacks information on exactly how to use this new feature.
> I dug into the git diff documentation here:
>
> https://git-scm.com/docs/git-diff
>
> It mentions a "--compaction-heuristic" option. Is this the new
> heuristic outlined by the release notes?

yes.

> Is the
> compaction heuristic compatible with the histogram diff algorithm?

yes as the compaction heuristic is applied after the actual diff is performed.

> Is
> there a config option to turn this on all the time? For that matter,
> is this something I can keep on all the time or is it only useful in
> certain situations?

I think you can set diff.compactionHeuristic and it will use it by default.

>
> There's still so much more about this feature I would like to know.

The background story (and what this new compaction heuristic is doing)
is found at https://github.com/mhagger/diff-slider-tools

```

## Jeff King, 2016-11-22 17:55

Subject: Re: v2.11 new diff heuristic?
Message-ID: <20161122175550.mlxzt3kgw3hj52qh@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20161122175550.mlxzt3kgw3hj52qh%40sigill.intra.peff.net
In-Reply-To: <CAHd499AjXh1YnVgBj_8j0fgvOgOn53y+sPBBy6y7mSM-+dCyVw@mail.gmail.com>

```
On Tue, Nov 22, 2016 at 08:42:36AM -0600, Robert Dailey wrote:

> I dug into the git diff documentation here:
> 
> https://git-scm.com/docs/git-diff
> 
> It mentions a "--compaction-heuristic" option. Is this the new
> heuristic outlined by the release notes? If not, which is it?

No. The docs on git-scm.com are only for released versions, so that is
the "old" attempt at a similar feature from v2.9. The "new" one goes by
the name "--indent-heuristic" (and "diff.indentHeuristic" in the
config). It is not the default in v2.11, but it probably will become so
in a future version.

> Is the
> compaction heuristic compatible with the histogram diff algorithm? Is
> there a config option to turn this on all the time? For that matter,
> is this something I can keep on all the time or is it only useful in
> certain situations?
> 
> There's still so much more about this feature I would like to know.

Yes, you can keep it all the time. Yes, it's compatible with histogram
(and patience); it happens as a separate post-processing step after the
actual diff.

You can find more discussion about how it works in the commit message of
433860f3d0beb0c6f205290bd16cda413148f098.

-Peff

```
