{"thread":{"id":"53020","subject":"Re: [GSoC][RFC] Convert mergetool to builtin","startedAt":"2020-03-18T16:31:22Z","lastAt":"2020-03-22T11:27:22Z","messageCount":3,"participants":["Abhishek Kumar","Kaartic Sivaraam","Christian Couder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"393401","messageId":"CAHk66fu7dZ4H8tvnbxfdBRcRdx-3f_cJSdVAoKrE3UbR3nehfA@mail.gmail.com","threadId":"53020","inReplyTo":null,"subject":"Re: [GSoC][RFC] Convert mergetool to builtin","fromName":"Abhishek Kumar","fromEmail":"abhishekkumar8222@gmail.com","sentAt":"2020-03-18T16:30:00Z","receivedAt":"2020-03-18T16:31:22Z","isPatch":false,"sender":{"key":"abhishekkumar8222@gmail.com","avatar":"https://avatars.githubusercontent.com/u/31231064?v=4"},"body":"Hello Christian\n\nSorry for the late reply - the work on the interval based graph labels has\nbeen pretty chaotic. I am going to roll out the second version of this\nproposal soon.\n\nIn the meantime,\n\n> Hi,\n>\n> [...]\n>> ### Conversion of mergetool--lib\n>>\n>> As mentioned earlier, conversion of the mergetool-related scripts has to be\n>> spread over 2-3 SoC or similar projects due to the size of scripts involved.\n>> Conversion of mergetool would set up most of the plumbing required for\n>> mergetool--lib and makes the subsequent conversion possible.\n>\n> I wonder if it would be better to convert git-mergetool--lib.sh first\n> and then git-difftool--helper.sh and git-mergetool.sh that are using\n> it.\n\nI had been agonizing over this decision while I was initially writing\nthe proposal.\n\nMy justifications for mergetool.sh over mergetool--lib.sh at the time were:\n\n1. mergetool.sh makes many more calls to git subcommands than mergetool--lib.\nTherefore, its performance improves from both moving from bash to C and use of\ngit internals.\n2. I had *incorrectly* counted overall lines to be over 1,700 with\n1,200 lines for mergetool--lib + difftool--helper + mergetools/ whereas it\nactually stands at rather manageable 1,000 lines with mergetools/ being fairly\nformulaic.\n\nThere are solid reasons to consider the conversion of mergetool--lib too:\n1. The code path of difftool-helper would be entirely in C, improving its\nperformance on Windows particularly well.\n2. It has two well-defined entry points, which makes conversion straightforward\nand with less code churn.\n3. It could be done with the more frequently-adopted approach of script\ncalling the builtin.\n\nAs it stands now, I am open to converting either scripts.\n\nI have CC'ed Johannes as well. I am sure he would like to weigh in\nthis discussion.\n\n> [...]\n>\n>> `get_merge_tool` decides the external tool. This function is used by\n>> both mergetool--lib and difftool--helper.\n>\n> Isn't this function defined in git-mergetool--lib.sh and used by\n> git-mergetool.sh?\n\nYes, thanks for correcting it.\n\n> [...]\n>\n>> ## Plan\n>>\n>> Similar to the conversion of difftool, I plan to create a builtin that shells\n>> out to a helper script. Once mergetool--lib is converted, we can retire the\n>> helper script and conversion would be complete.\n>\n> So you plan to create a builtin that would shell out to git-mergetool--lib.sh?\n>\n> Could you be clearer about what the conversion of difftool did and how\n> you plan to imitate that?\n\nConversion of difftool had three patches:\n\n1. difftool: add a skeleton for the upcoming builtin\n- Rename git-difftool.perl to git-legacy-difftool.perl\n- Create builtin/difftool.c which executes git-legacy-difftool.perl\n- Add difftool to builtin.h\n- Add \"difftool.usebuiltin\" configuration option\n- Modify build process\n\n2. difftool: implement the functionality in the builtin\n\n3. difftool: retire the legacy script\n- Remove git-legacy-difftool.perl from the build process\n- Remove outdated \"NEEDWORK\" comments\n- Remove perl dependency from test file\n\nSince most of the conversion was done in a single commit, it is hard to talk\nabout the exact order of changes. Johannes, could you please guide us through\nthe process?\n\nSimilar to this, my changes can be grouped as:\n\n1. Create a skeleton builtin.\n2. Implement scaffolding, implement shared functions, teach builtin to resolve\nsymlink, submodule and deleted file conflicts, and others. They form the core\nfunctionality of mergetool.\n3. Teach builtin to shell out for file conflict (at which we retire\nmergetool.sh)\n\n> [...]\n>\n>> 8. Teach builtin to assign merge tool (July 10 - July 15)\n>> - Convert `get_configured_merge_tool` from mergetool--lib\n>> - Around 50 lines\n>\n> Ok, so at this point you start to convert git-mergetool--lib.sh. Where\n> is the converted code going to be? Does git-difftool--helper.sh needs\n> what you will convert?\n\nYes. Some functions like get_configured_merge_tool, guess_merge_tool are only\nused by mergetool and can be moved to builtin/mergetool.c.\n\n> [...]\n>\n>> 9. Teach builtin to shell out for file conflict (July 15 - July 31)\n>>  - Write a minimal mergetool--helper.sh (similar to difftool--helper.sh)\n>> - Call the helper script from the builtin\n>> - Retire the legacy script.\n>\n> Which legacy script?\n\ngit-mergetool.sh was renamed to git-legacy-mergetool.sh back in first step.\n\n> [...]\n\nRegards\nAbhishek\n"},{"id":"393441","messageId":"1bb8e4f9-6e6e-0874-b1ef-47eccf93a98b@gmail.com","threadId":"53020","inReplyTo":"CAHk66fu7dZ4H8tvnbxfdBRcRdx-3f_cJSdVAoKrE3UbR3nehfA@mail.gmail.com","subject":"Re: [GSoC][RFC] Convert mergetool to builtin","fromName":"Kaartic Sivaraam","fromEmail":"kaartic.sivaraam@gmail.com","sentAt":"2020-03-19T08:42:16Z","receivedAt":"2020-03-19T08:43:42Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"Hi Abishek,\n\nJust wanted to share a general suggestion which is not related to your \nproposal. In future, when you quote a portion of the e-mail retain the \ncomplete meta information about the quote (like the one you see below) \nor the person who wrote the quoted portion at the very least. It helps \npeople who join late in the discussion to *quickly* get up-to-speed with \nthe discussion.\n\nAnyways, good luck with your proposal. :)\n\nOn 18-03-2020 22:00, Abhishek Kumar wrote:\n>>> ### Conversion of mergetool--lib\n>>>\n>>> As mentioned earlier, conversion of the mergetool-related scripts has to be\n>>> spread over 2-3 SoC or similar projects due to the size of scripts involved.\n>>> Conversion of mergetool would set up most of the plumbing required for\n>>> mergetool--lib and makes the subsequent conversion possible.\n>>\n>> I wonder if it would be better to convert git-mergetool--lib.sh first\n>> and then git-difftool--helper.sh and git-mergetool.sh that are using\n>> it.\n> \n> I had been agonizing over this decision while I was initially writing\n> the proposal.\n> \n> My justifications for mergetool.sh over mergetool--lib.sh at the time were:\n> \n> 1. mergetool.sh makes many more calls to git subcommands than mergetool--lib.\n> Therefore, its performance improves from both moving from bash to C and use of\n> git internals.\n> 2. I had *incorrectly* counted overall lines to be over 1,700 with\n> 1,200 lines for mergetool--lib + difftool--helper + mergetools/ whereas it\n> actually stands at rather manageable 1,000 lines with mergetools/ being fairly\n> formulaic.\n> \n> There are solid reasons to consider the conversion of mergetool--lib too:\n> 1. The code path of difftool-helper would be entirely in C, improving its\n> performance on Windows particularly well.\n> 2. It has two well-defined entry points, which makes conversion straightforward\n> and with less code churn.\n> 3. It could be done with the more frequently-adopted approach of script\n> calling the builtin.\n> \n> As it stands now, I am open to converting either scripts.\n> \n> I have CC'ed Johannes as well. I am sure he would like to weigh in\n> this discussion.\n> \n--\nSivaraam\n"},{"id":"393702","messageId":"CAP8UFD0T4OXaTyVYhkG56Gko=qtUAA1bVfyKNbX05Xprwe__Bg@mail.gmail.com","threadId":"53020","inReplyTo":"CAHk66fu7dZ4H8tvnbxfdBRcRdx-3f_cJSdVAoKrE3UbR3nehfA@mail.gmail.com","subject":"Re: [GSoC][RFC] Convert mergetool to builtin","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2020-03-22T11:27:06Z","receivedAt":"2020-03-22T11:27:22Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi Abhishek,\n\nOn Wed, Mar 18, 2020 at 5:31 PM Abhishek Kumar\n<abhishekkumar8222@gmail.com> wrote:\n>\n> Hello Christian\n>\n> Sorry for the late reply - the work on the interval based graph labels has\n> been pretty chaotic. I am going to roll out the second version of this\n> proposal soon.\n\nGreat!\n\n> In the meantime,\n>\n> > [...]\n> >> ### Conversion of mergetool--lib\n> >>\n> >> As mentioned earlier, conversion of the mergetool-related scripts has to be\n> >> spread over 2-3 SoC or similar projects due to the size of scripts involved.\n> >> Conversion of mergetool would set up most of the plumbing required for\n> >> mergetool--lib and makes the subsequent conversion possible.\n> >\n> > I wonder if it would be better to convert git-mergetool--lib.sh first\n> > and then git-difftool--helper.sh and git-mergetool.sh that are using\n> > it.\n>\n> I had been agonizing over this decision while I was initially writing\n> the proposal.\n>\n> My justifications for mergetool.sh over mergetool--lib.sh at the time were:\n\n[...]\n\n> As it stands now, I am open to converting either scripts.\n\nIt's ok to give all the above arguments in your proposal, and then to\nsay that you studied how to convert one of the possible scripts more\nand that's the reason you choose to convert it in your proposal.\n\n> >> ## Plan\n> >>\n> >> Similar to the conversion of difftool, I plan to create a builtin that shells\n> >> out to a helper script. Once mergetool--lib is converted, we can retire the\n> >> helper script and conversion would be complete.\n> >\n> > So you plan to create a builtin that would shell out to git-mergetool--lib.sh?\n> >\n> > Could you be clearer about what the conversion of difftool did and how\n> > you plan to imitate that?\n>\n> Conversion of difftool had three patches:\n>\n> 1. difftool: add a skeleton for the upcoming builtin\n> - Rename git-difftool.perl to git-legacy-difftool.perl\n> - Create builtin/difftool.c which executes git-legacy-difftool.perl\n> - Add difftool to builtin.h\n> - Add \"difftool.usebuiltin\" configuration option\n> - Modify build process\n>\n> 2. difftool: implement the functionality in the builtin\n>\n> 3. difftool: retire the legacy script\n> - Remove git-legacy-difftool.perl from the build process\n> - Remove outdated \"NEEDWORK\" comments\n> - Remove perl dependency from test file\n>\n> Since most of the conversion was done in a single commit, it is hard to talk\n> about the exact order of changes.\n\nIt's ok to just say all the above in your proposal.\n\n> Similar to this, my changes can be grouped as:\n>\n> 1. Create a skeleton builtin.\n> 2. Implement scaffolding, implement shared functions, teach builtin to resolve\n> symlink, submodule and deleted file conflicts, and others. They form the core\n> functionality of mergetool.\n> 3. Teach builtin to shell out for file conflict (at which we retire\n> mergetool.sh)\n\nOk, to group however you want. What I am just saying it's that's it's\nvaluable if your proposal shows more clearly how your steps or\nthe way you group the changes corresponds to what was done for difftool.\n\n> >> 8. Teach builtin to assign merge tool (July 10 - July 15)\n> >> - Convert `get_configured_merge_tool` from mergetool--lib\n> >> - Around 50 lines\n> >\n> > Ok, so at this point you start to convert git-mergetool--lib.sh. Where\n> > is the converted code going to be? Does git-difftool--helper.sh needs\n> > what you will convert?\n>\n> Yes. Some functions like get_configured_merge_tool, guess_merge_tool are only\n> used by mergetool and can be moved to builtin/mergetool.c.\n\nOk.\n\n> >> 9. Teach builtin to shell out for file conflict (July 15 - July 31)\n> >>  - Write a minimal mergetool--helper.sh (similar to difftool--helper.sh)\n> >> - Call the helper script from the builtin\n> >> - Retire the legacy script.\n> >\n> > Which legacy script?\n>\n> git-mergetool.sh was renamed to git-legacy-mergetool.sh back in first step.\n\nOk.\n\nI hope to see the above answers in the next version of your proposal.\n\nBest,\nChristian.\n"}]}