[GSoC][PATCH] merge: use reverse_commit_list() for list reversal
From: Kousik Sanagavarapu <hidden>
Date: 2023-02-02 16:53:23
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Kousik Sanagavarapu <hidden>
Date: 2023-02-02 16:53:23
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted> --- 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