git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GSoC][PATCH] merge: use reverse_commit_list() for list reversal
@ 2023-02-02 16:51 Kousik Sanagavarapu
  2023-02-02 23:06 ` Junio C Hamano
  2023-02-02 23:46 ` Elijah Newren
  0 siblings, 2 replies; 11+ messages in thread
From: Kousik Sanagavarapu @ 2023-02-02 16:51 UTC (permalink / raw)
  To: git; +Cc: Kousik Sanagavarapu

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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-02-05 18:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CABPp-BHnXy+Hpv4y83znMxDGOTCZQfYhnDon=ehBDGOxAnW1vQ@mail.gmail.com--to=newren@gmail.com>
2023-02-05 17:31 ` [GSoC][PATCH] merge: use reverse_commit_list() for list reversal Kousik Sanagavarapu
2023-02-02 16:51 Kousik Sanagavarapu
2023-02-02 23:06 ` 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

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).