git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kousik Sanagavarapu <five231003@gmail.com>
To: git@vger.kernel.org
Cc: Kousik Sanagavarapu <five231003@gmail.com>
Subject: [GSoC][PATCH] merge: use reverse_commit_list() for list reversal
Date: Thu,  2 Feb 2023 22:21:41 +0530	[thread overview]
Message-ID: <20230202165137.118741-1-five231003@gmail.com> (raw)

Instead of manually doing an in-place list reversal, use the helper
function reverse_commit_list(), hence improving code readability.

Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
---

This patch addresses the issue #1156(Use reverse_commit_list() in more
places) on gitgitgadget. I also would like to submit this patch as the microproject for
GSoC 2023.

 builtin/merge.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index 5900b81729..4503dbfeb3 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -736,7 +736,6 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 		struct commit *result;
 		struct commit_list *reversed = NULL;
 		struct merge_options o;
-		struct commit_list *j;
 
 		if (remoteheads->next) {
 			error(_("Not handling anything other than two heads merge."));
@@ -757,8 +756,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
 		o.branch1 = head_arg;
 		o.branch2 = merge_remote_util(remoteheads->item)->name;
 
-		for (j = common; j; j = j->next)
-			commit_list_insert(j->item, &reversed);
+		reversed = reverse_commit_list(common);
 
 		hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
 		if (!strcmp(strategy, "ort"))
-- 
2.25.1


             reply	other threads:[~2023-02-02 16:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 16:51 Kousik Sanagavarapu [this message]
2023-02-02 23:06 ` [GSoC][PATCH] merge: use reverse_commit_list() for list reversal Junio C Hamano
2023-02-03 17:11   ` Kousik Sanagavarapu
2023-02-03 17:30   ` Kousik Sanagavarapu
2023-02-02 23:46 ` Elijah Newren
2023-02-03 17:49   ` Kousik Sanagavarapu
2023-02-03 18:02     ` Elijah Newren
2023-02-03 19:07       ` Junio C Hamano
2023-02-05 18:12         ` Kousik Sanagavarapu
2023-02-05 17:32       ` Kousik Sanagavarapu
     [not found] <CABPp-BHnXy+Hpv4y83znMxDGOTCZQfYhnDon=ehBDGOxAnW1vQ@mail.gmail.com--to=newren@gmail.com>
2023-02-05 17:31 ` Kousik Sanagavarapu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230202165137.118741-1-five231003@gmail.com \
    --to=five231003@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).