{"thread":{"id":"57558","subject":"Re: [PATCH 1/1] Use reverse_commit_list helper function for in-place list reversal","startedAt":"2022-03-14T12:10:31Z","lastAt":"2022-03-16T11:32:18Z","messageCount":3,"participants":["Jayati Shrivastava","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"451307","messageId":"CANsrJQd0v2V9H8HPkiH2179C1c-NOSTRRB8YXt8v6R0YAbFPDQ@mail.gmail.com","threadId":"57558","inReplyTo":"20220314080601.10504-1-gaurijove@gmail.com","subject":"Re: [PATCH 1/1] Use reverse_commit_list helper function for in-place list reversal","fromName":"Jayati Shrivastava","fromEmail":"gaurijove@gmail.com","sentAt":"2022-03-14T12:03:57Z","receivedAt":"2022-03-14T12:10:31Z","isPatch":true,"sender":{"key":"gaurijove@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48182195?v=4"},"body":"This patch addresses https://github.com/gitgitgadget/git/issues/1156 . I have\nleft builtin/merge.c unmodified since in its case, the original list\nis needed separately\nfrom its reverse copy.\n\nOn Mon, Mar 14, 2022 at 1:36 PM JAYATI SHRIVASTAVA <gaurijove@gmail.com> wrote:\n>\n> From: JAYATI SHRIVASTAVA <gaurijove@gmail.com>\n>\n> Here, a reverse copy of the list is being created by looping and the\n> original list is no longer used by the code. Therefore, instead of creating a copy,\n> we can reverse the original list in-place using the reverse_commit_list helper\n> function a copy.\n>\n> Signed-off-by: JAYATI SHRIVASTAVA <gaurijove@gmail.com>\n> ---\n>  sequencer.c | 10 ++++------\n>  1 file changed, 4 insertions(+), 6 deletions(-)\n>\n> diff --git a/sequencer.c b/sequencer.c\n> index 35006c0cea..bccbb9e352 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -3749,7 +3749,7 @@ static int do_merge(struct repository *r,\n>         int run_commit_flags = 0;\n>         struct strbuf ref_name = STRBUF_INIT;\n>         struct commit *head_commit, *merge_commit, *i;\n> -       struct commit_list *bases, *j, *reversed = NULL;\n> +       struct commit_list *bases, *j;\n>         struct commit_list *to_merge = NULL, **tail = &to_merge;\n>         const char *strategy = !opts->xopts_nr &&\n>                 (!opts->strategy ||\n> @@ -3984,9 +3984,7 @@ static int do_merge(struct repository *r,\n>                       git_path_merge_head(r), 0);\n>         write_message(\"no-ff\", 5, git_path_merge_mode(r), 0);\n>\n> -       for (j = bases; j; j = j->next)\n> -               commit_list_insert(j->item, &reversed);\n> -       free_commit_list(bases);\n> +       bases = reverse_commit_list(bases);\n>\n>         repo_read_index(r);\n>         init_merge_options(&o, r);\n> @@ -4002,10 +4000,10 @@ static int do_merge(struct repository *r,\n>                  * update the index and working copy immediately.\n>                  */\n>                 ret = merge_ort_recursive(&o,\n> -                                         head_commit, merge_commit, reversed,\n> +                                         head_commit, merge_commit, bases,\n>                                           &i);\n>         } else {\n> -               ret = merge_recursive(&o, head_commit, merge_commit, reversed,\n> +               ret = merge_recursive(&o, head_commit, merge_commit, bases,\n>                                       &i);\n>         }\n>         if (ret <= 0)\n> --\n> 2.35.1.455.g1a4874565f\n>\n"},{"id":"451459","messageId":"nycvar.QRO.7.76.6.2203161028560.357@tvgsbejvaqbjf.bet","threadId":"57558","inReplyTo":"CANsrJQd0v2V9H8HPkiH2179C1c-NOSTRRB8YXt8v6R0YAbFPDQ@mail.gmail.com","subject":"Re: [PATCH 1/1] Use reverse_commit_list helper function for in-place list reversal","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2022-03-16T09:29:22Z","receivedAt":"2022-03-16T09:29:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Jayati,\n\nOn Mon, 14 Mar 2022, Jayati Shrivastava wrote:\n\n> This patch addresses https://github.com/gitgitgadget/git/issues/1156 . I have\n> left builtin/merge.c unmodified since in its case, the original list\n> is needed separately\n> from its reverse copy.\n\nThis information is quite useful. Can you please integrate it into the\ncommit message before sending the next iteration?\n\nThank you,\nDscho\n"},{"id":"451465","messageId":"CANsrJQcfSrmgCQn6ozvhunPXK6zfg33j40nQS0b70xnvJWO8iw@mail.gmail.com","threadId":"57558","inReplyTo":"nycvar.QRO.7.76.6.2203161028560.357@tvgsbejvaqbjf.bet","subject":"Re: [PATCH 1/1] Use reverse_commit_list helper function for in-place list reversal","fromName":"Jayati Shrivastava","fromEmail":"gaurijove@gmail.com","sentAt":"2022-03-16T11:32:02Z","receivedAt":"2022-03-16T11:32:18Z","isPatch":true,"sender":{"key":"gaurijove@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48182195?v=4"},"body":"Hi Dsho,\n\nThanks for reviewing.\n\nOn Wed, Mar 16, 2022 at 2:59 PM Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n\n> This information is quite useful. Can you please integrate it into the\n> commit message before sending the next iteration?\n\nI have incorporated the changes here :\nhttps://lore.kernel.org/git/pull.1177.v3.git.1647429623830.gitgitgadget@gmail.com/\n.\nI had to shift to another thread using Gitgadget since the patches\nthat I am mailing using git send-email were not getting delivered to the\npublic mailing list\n"}]}