# indent-heuristic, compaction-heuristic combination

4 messages from 2016-12-17 to 2016-12-17. Participants: Norbert Kiesel, Jacob Keller.
Thread: https://gitlist.dev/t/44721

## Norbert Kiesel, 2016-12-17 00:28

Subject: indent-heuristic, compaction-heuristic combination
Message-ID: <CAM+g_NsDLKxWLZCDOgrh2O3W23PRP8Zxf-Zzf_twSw5VX3=G=A@mail.gmail.com>
URL: https://gitlist.dev/e/CAM%2Bg_NsDLKxWLZCDOgrh2O3W23PRP8Zxf-Zzf_twSw5VX3%3DG%3DA%40mail.gmail.com

```
Hi,

I started using compaction-heuristic with 2.9, and then also (or so I
thought) enabled indent-heuristic with 2.11.
Only after reading a comment in "Git rev news" I realized that these 2
options are mutually exclusive.  I then
checked the Git source code and saw that Git first checks the new
indent-heuristic and then the old compaction-heuristic.
Therefore, anyone who is as stupid as me and enabled both will always
(and silently) end up with the older of the
two.

Apart from better documentation (I know that both are marked
experimental, but nevertheless): could we not swap the
order in which they are tested so that the newer heuristic wins?

</nk>

```

## Jacob Keller, 2016-12-17 00:37

Subject: Re: indent-heuristic, compaction-heuristic combination
Message-ID: <CA+P7+xpwL+jw=eJhBH6xTPCJoDrzXBHj4p86xtyMZ++eyyHkTA@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BP7%2BxpwL%2Bjw%3DeJhBH6xTPCJoDrzXBHj4p86xtyMZ%2B%2BeyyHkTA%40mail.gmail.com
In-Reply-To: <CAM+g_NsDLKxWLZCDOgrh2O3W23PRP8Zxf-Zzf_twSw5VX3=G=A@mail.gmail.com>

```
On Fri, Dec 16, 2016 at 4:28 PM, Norbert Kiesel <nkiesel@gmail.com> wrote:
> Hi,
>
> I started using compaction-heuristic with 2.9, and then also (or so I
> thought) enabled indent-heuristic with 2.11.
> Only after reading a comment in "Git rev news" I realized that these 2
> options are mutually exclusive.  I then
> checked the Git source code and saw that Git first checks the new
> indent-heuristic and then the old compaction-heuristic.
> Therefore, anyone who is as stupid as me and enabled both will always
> (and silently) end up with the older of the
> two.
>
> Apart from better documentation (I know that both are marked
> experimental, but nevertheless): could we not swap the
> order in which they are tested so that the newer heuristic wins?
>
> </nk>

This seems reasonable to me.

Thanks,
Jake

```

## Jacob Keller, 2016-12-17 00:44

Subject: Re: indent-heuristic, compaction-heuristic combination
Message-ID: <CA+P7+xqBwdoHNVFrgwFXn48YtggatrFiBwbAt6+KZ+iG4oznqw@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BP7%2BxqBwdoHNVFrgwFXn48YtggatrFiBwbAt6%2BKZ%2BiG4oznqw%40mail.gmail.com
In-Reply-To: <CAM+g_NsDLKxWLZCDOgrh2O3W23PRP8Zxf-Zzf_twSw5VX3=G=A@mail.gmail.com>

```
On Fri, Dec 16, 2016 at 4:28 PM, Norbert Kiesel <nkiesel@gmail.com> wrote:
> Hi,
>
> I started using compaction-heuristic with 2.9, and then also (or so I
> thought) enabled indent-heuristic with 2.11.
> Only after reading a comment in "Git rev news" I realized that these 2
> options are mutually exclusive.  I then
> checked the Git source code and saw that Git first checks the new
> indent-heuristic and then the old compaction-heuristic.
> Therefore, anyone who is as stupid as me and enabled both will always
> (and silently) end up with the older of the
> two.
>
> Apart from better documentation (I know that both are marked
> experimental, but nevertheless): could we not swap the
> order in which they are tested so that the newer heuristic wins?
>
> </nk>

I looked at the code and I don't think this is the case. In
diff_setup() on line 3381, we check indent heuristic first. However,
when we check the compaction heuristic second, we use an "else if" so
we do not set both. I believe it already performs indent heuristic
correctly if you enable both options in configuration.

Thanks,
Jake

```

## Jacob Keller, 2016-12-17 00:45

Subject: Re: indent-heuristic, compaction-heuristic combination
Message-ID: <CA+P7+xqECPzGd0MoXXDM6m7LMiYXs4=U+pUey7BRLfv+XQYJ_A@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BP7%2BxqECPzGd0MoXXDM6m7LMiYXs4%3DU%2BpUey7BRLfv%2BXQYJ_A%40mail.gmail.com
In-Reply-To: <CA+P7+xqBwdoHNVFrgwFXn48YtggatrFiBwbAt6+KZ+iG4oznqw@mail.gmail.com>

```
On Fri, Dec 16, 2016 at 4:44 PM, Jacob Keller <jacob.keller@gmail.com> wrote:
> On Fri, Dec 16, 2016 at 4:28 PM, Norbert Kiesel <nkiesel@gmail.com> wrote:
>> Hi,
>>
>> I started using compaction-heuristic with 2.9, and then also (or so I
>> thought) enabled indent-heuristic with 2.11.
>> Only after reading a comment in "Git rev news" I realized that these 2
>> options are mutually exclusive.  I then
>> checked the Git source code and saw that Git first checks the new
>> indent-heuristic and then the old compaction-heuristic.
>> Therefore, anyone who is as stupid as me and enabled both will always
>> (and silently) end up with the older of the
>> two.
>>
>> Apart from better documentation (I know that both are marked
>> experimental, but nevertheless): could we not swap the
>> order in which they are tested so that the newer heuristic wins?
>>
>> </nk>
>
> I looked at the code and I don't think this is the case. In
> diff_setup() on line 3381, we check indent heuristic first. However,
> when we check the compaction heuristic second, we use an "else if" so
> we do not set both. I believe it already performs indent heuristic
> correctly if you enable both options in configuration.
>
> Thanks,
> Jake

On further looking, I realized again that maybe you are right. I will
send a patch to change the other spot where we might prefer the older
heuristic.

Thanks,
Jake

```
