threads / discuss / 44721

indent-heuristic, compaction-heuristic combination

Subject: indent-heuristic, compaction-heuristic combination

## tl;dr

4 messages between Dec 17, 2016 and Dec 17, 2016.

replies: 3people: 2as markdown or json

Norbert Kiesel· Dec 17, 2016, 00:28 UTC · lore
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· Dec 17, 2016, 00:37 UTC · re: Norbert Kiesel · lore

Re: indent-heuristic, compaction-heuristic combination

On Fri, Dec 16, 2016 at 4:28 PM, Norbert Kiesel <nkiesel@gmail.com> wrote:
Show 17 quoted lines
> 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· Dec 17, 2016, 00:44 UTC · re: Norbert Kiesel · lore

Re: indent-heuristic, compaction-heuristic combination

On Fri, Dec 16, 2016 at 4:28 PM, Norbert Kiesel <nkiesel@gmail.com> wrote:
Show 17 quoted lines
> 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· Dec 17, 2016, 00:45 UTC · re: Jacob Keller · lore

Re: indent-heuristic, compaction-heuristic combination

On Fri, Dec 16, 2016 at 4:44 PM, Jacob Keller <jacob.keller@gmail.com> wrote:
Show 27 quoted lines
> 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

← back to recent threads