threads / rfc / 53020

Re: [GSoC][RFC] Convert mergetool to builtin

Subject: Re: [GSoC][RFC] Convert mergetool to builtin

## tl;dr

3 messages between Mar 18, 2020 and Mar 22, 2020.

replies: 2people: 3as markdown or json

Abhishek Kumar· Mar 18, 2020, 16:30 UTC · lore
Hello Christian

Sorry for the late reply - the work on the interval based graph labels has been pretty chaotic. I am going to roll out the second version of this proposal soon.

In the meantime,
Show 13 quoted lines
> Hi,
>
> [...]
>> ### Conversion of mergetool--lib
>>
>> As mentioned earlier, conversion of the mergetool-related scripts has to be
>> spread over 2-3 SoC or similar projects due to the size of scripts involved.
>> Conversion of mergetool would set up most of the plumbing required for
>> mergetool--lib and makes the subsequent conversion possible.
>
> I wonder if it would be better to convert git-mergetool--lib.sh first
> and then git-difftool--helper.sh and git-mergetool.sh that are using
> it.

I had been agonizing over this decision while I was initially writing the proposal.

My justifications for mergetool.sh over mergetool--lib.sh at the time were:
1. mergetool.sh makes many more calls to git subcommands than mergetool--lib.
Therefore, its performance improves from both moving from bash to C and use of
git internals.
2. I had *incorrectly* counted overall lines to be over 1,700 with
1,200 lines for mergetool--lib + difftool--helper + mergetools/ whereas it
actually stands at rather manageable 1,000 lines with mergetools/ being fairly
formulaic.
There are solid reasons to consider the conversion of mergetool--lib too:
1. The code path of difftool-helper would be entirely in C, improving its
performance on Windows particularly well.
2. It has two well-defined entry points, which makes conversion straightforward
and with less code churn.
3. It could be done with the more frequently-adopted approach of script
calling the builtin.
As it stands now, I am open to converting either scripts.

I have CC'ed Johannes as well. I am sure he would like to weigh in this discussion.

Show 7 quoted lines
> [...]
>
>> `get_merge_tool` decides the external tool. This function is used by
>> both mergetool--lib and difftool--helper.
>
> Isn't this function defined in git-mergetool--lib.sh and used by
> git-mergetool.sh?
Yes, thanks for correcting it.
Show 12 quoted lines
> [...]
>
>> ## Plan
>>
>> Similar to the conversion of difftool, I plan to create a builtin that shells
>> out to a helper script. Once mergetool--lib is converted, we can retire the
>> helper script and conversion would be complete.
>
> So you plan to create a builtin that would shell out to git-mergetool--lib.sh?
>
> Could you be clearer about what the conversion of difftool did and how
> you plan to imitate that?
Conversion of difftool had three patches:
1. difftool: add a skeleton for the upcoming builtin
- Rename git-difftool.perl to git-legacy-difftool.perl
- Create builtin/difftool.c which executes git-legacy-difftool.perl
- Add difftool to builtin.h
- Add "difftool.usebuiltin" configuration option
- Modify build process
2. difftool: implement the functionality in the builtin
3. difftool: retire the legacy script
- Remove git-legacy-difftool.perl from the build process
- Remove outdated "NEEDWORK" comments
- Remove perl dependency from test file

Since most of the conversion was done in a single commit, it is hard to talk about the exact order of changes. Johannes, could you please guide us through the process?

Similar to this, my changes can be grouped as:
1. Create a skeleton builtin.
2. Implement scaffolding, implement shared functions, teach builtin to resolve
symlink, submodule and deleted file conflicts, and others. They form the core
functionality of mergetool.
3. Teach builtin to shell out for file conflict (at which we retire
mergetool.sh)
Show 9 quoted lines
> [...]
>
>> 8. Teach builtin to assign merge tool (July 10 - July 15)
>> - Convert `get_configured_merge_tool` from mergetool--lib
>> - Around 50 lines
>
> Ok, so at this point you start to convert git-mergetool--lib.sh. Where
> is the converted code going to be? Does git-difftool--helper.sh needs
> what you will convert?

Yes. Some functions like get_configured_merge_tool, guess_merge_tool are only used by mergetool and can be moved to builtin/mergetool.c.

Show 8 quoted lines
> [...]
>
>> 9. Teach builtin to shell out for file conflict (July 15 - July 31)
>>  - Write a minimal mergetool--helper.sh (similar to difftool--helper.sh)
>> - Call the helper script from the builtin
>> - Retire the legacy script.
>
> Which legacy script?
git-mergetool.sh was renamed to git-legacy-mergetool.sh back in first step.
> [...]

Regards Abhishek

Kaartic Sivaraam· Mar 19, 2020, 08:42 UTC · re: Abhishek Kumar · lore
Hi Abishek,

Just wanted to share a general suggestion which is not related to your proposal. In future, when you quote a portion of the e-mail retain the complete meta information about the quote (like the one you see below) or the person who wrote the quoted portion at the very least. It helps people who join late in the discussion to *quickly* get up-to-speed with the discussion.

Anyways, good luck with your proposal. :)
On 18-03-2020 22:00, Abhishek Kumar wrote:
Show 37 quoted lines
>>> ### Conversion of mergetool--lib
>>>
>>> As mentioned earlier, conversion of the mergetool-related scripts has to be
>>> spread over 2-3 SoC or similar projects due to the size of scripts involved.
>>> Conversion of mergetool would set up most of the plumbing required for
>>> mergetool--lib and makes the subsequent conversion possible.
>>
>> I wonder if it would be better to convert git-mergetool--lib.sh first
>> and then git-difftool--helper.sh and git-mergetool.sh that are using
>> it.
> 
> I had been agonizing over this decision while I was initially writing
> the proposal.
> 
> My justifications for mergetool.sh over mergetool--lib.sh at the time were:
> 
> 1. mergetool.sh makes many more calls to git subcommands than mergetool--lib.
> Therefore, its performance improves from both moving from bash to C and use of
> git internals.
> 2. I had *incorrectly* counted overall lines to be over 1,700 with
> 1,200 lines for mergetool--lib + difftool--helper + mergetools/ whereas it
> actually stands at rather manageable 1,000 lines with mergetools/ being fairly
> formulaic.
> 
> There are solid reasons to consider the conversion of mergetool--lib too:
> 1. The code path of difftool-helper would be entirely in C, improving its
> performance on Windows particularly well.
> 2. It has two well-defined entry points, which makes conversion straightforward
> and with less code churn.
> 3. It could be done with the more frequently-adopted approach of script
> calling the builtin.
> 
> As it stands now, I am open to converting either scripts.
> 
> I have CC'ed Johannes as well. I am sure he would like to weigh in
> this discussion.
> 

-- Sivaraam

Christian Couder· Mar 22, 2020, 11:27 UTC · re: Abhishek Kumar · lore
Hi Abhishek,

On Wed, Mar 18, 2020 at 5:31 PM Abhishek Kumar <abhishekkumar8222@gmail.com> wrote:

Show 6 quoted lines
>
> Hello Christian
>
> Sorry for the late reply - the work on the interval based graph labels has
> been pretty chaotic. I am going to roll out the second version of this
> proposal soon.
Great!
Show 18 quoted lines
> In the meantime,
>
> > [...]
> >> ### Conversion of mergetool--lib
> >>
> >> As mentioned earlier, conversion of the mergetool-related scripts has to be
> >> spread over 2-3 SoC or similar projects due to the size of scripts involved.
> >> Conversion of mergetool would set up most of the plumbing required for
> >> mergetool--lib and makes the subsequent conversion possible.
> >
> > I wonder if it would be better to convert git-mergetool--lib.sh first
> > and then git-difftool--helper.sh and git-mergetool.sh that are using
> > it.
>
> I had been agonizing over this decision while I was initially writing
> the proposal.
>
> My justifications for mergetool.sh over mergetool--lib.sh at the time were:
[...]
> As it stands now, I am open to converting either scripts.

It's ok to give all the above arguments in your proposal, and then to say that you studied how to convert one of the possible scripts more and that's the reason you choose to convert it in your proposal.

Show 29 quoted lines
> >> ## Plan
> >>
> >> Similar to the conversion of difftool, I plan to create a builtin that shells
> >> out to a helper script. Once mergetool--lib is converted, we can retire the
> >> helper script and conversion would be complete.
> >
> > So you plan to create a builtin that would shell out to git-mergetool--lib.sh?
> >
> > Could you be clearer about what the conversion of difftool did and how
> > you plan to imitate that?
>
> Conversion of difftool had three patches:
>
> 1. difftool: add a skeleton for the upcoming builtin
> - Rename git-difftool.perl to git-legacy-difftool.perl
> - Create builtin/difftool.c which executes git-legacy-difftool.perl
> - Add difftool to builtin.h
> - Add "difftool.usebuiltin" configuration option
> - Modify build process
>
> 2. difftool: implement the functionality in the builtin
>
> 3. difftool: retire the legacy script
> - Remove git-legacy-difftool.perl from the build process
> - Remove outdated "NEEDWORK" comments
> - Remove perl dependency from test file
>
> Since most of the conversion was done in a single commit, it is hard to talk
> about the exact order of changes.
It's ok to just say all the above in your proposal.
Show 8 quoted lines
> Similar to this, my changes can be grouped as:
>
> 1. Create a skeleton builtin.
> 2. Implement scaffolding, implement shared functions, teach builtin to resolve
> symlink, submodule and deleted file conflicts, and others. They form the core
> functionality of mergetool.
> 3. Teach builtin to shell out for file conflict (at which we retire
> mergetool.sh)

Ok, to group however you want. What I am just saying it's that's it's valuable if your proposal shows more clearly how your steps or the way you group the changes corresponds to what was done for difftool.

Show 10 quoted lines
> >> 8. Teach builtin to assign merge tool (July 10 - July 15)
> >> - Convert `get_configured_merge_tool` from mergetool--lib
> >> - Around 50 lines
> >
> > Ok, so at this point you start to convert git-mergetool--lib.sh. Where
> > is the converted code going to be? Does git-difftool--helper.sh needs
> > what you will convert?
>
> Yes. Some functions like get_configured_merge_tool, guess_merge_tool are only
> used by mergetool and can be moved to builtin/mergetool.c.
Ok.
Show 8 quoted lines
> >> 9. Teach builtin to shell out for file conflict (July 15 - July 31)
> >>  - Write a minimal mergetool--helper.sh (similar to difftool--helper.sh)
> >> - Call the helper script from the builtin
> >> - Retire the legacy script.
> >
> > Which legacy script?
>
> git-mergetool.sh was renamed to git-legacy-mergetool.sh back in first step.
Ok.
I hope to see the above answers in the next version of your proposal.

Best, Christian.

← back to recent threads