git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] get_octopus_merge_bases(): cleanup redundant variable

From
Vasily Makarov <einmalfel@gmail.com>
Date
Jan 3, 2014, 19:01 UTC
Message-ID
<1388775675-12228-1-git-send-email-einmalfel@gmail.com>
In-Reply-To
<xmqqeh4oncpo.fsf@gitster.dls.corp.google.com>
pptr is needless. Some related code got cleaned as well
Signed-off-by: Vasily Makarov <einmalfel@gmail.com>
---
 commit.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/commit.c b/commit.c
index de16a3c..8e48c49 100644
--- a/commit.c
+++ b/commit.c
@@ -834,26 +834,26 @@ static struct commit_list *merge_bases_many(struct commit *one, int n, struct co
 struct commit_list *get_octopus_merge_bases(struct commit_list *in)
 {
 	struct commit_list *i, *j, *k, *ret = NULL;
-	struct commit_list **pptr = &ret;
 
-	for (i = in; i; i = i->next) {
-		if (!ret)
-			pptr = &commit_list_insert(i->item, pptr)->next;
-		else {
-			struct commit_list *new = NULL, *end = NULL;
-
-			for (j = ret; j; j = j->next) {
-				struct commit_list *bases;
-				bases = get_merge_bases(i->item, j->item, 1);
-				if (!new)
-					new = bases;
-				else
-					end->next = bases;
-				for (k = bases; k; k = k->next)
-					end = k;
-			}
-			ret = new;
+	if (!in)
+		return NULL;
+
+	commit_list_insert(in->item, &ret);
+
+	for (i = in->next; i; i = i->next) {
+		struct commit_list *new = NULL, *end = NULL;
+
+		for (j = ret; j; j = j->next) {
+			struct commit_list *bases;
+			bases = get_merge_bases(i->item, j->item, 1);
+			if (!new)
+				new = bases;
+			else
+				end->next = bases;
+			for (k = bases; k; k = k->next)
+				end = k;
 		}
+		ret = new;
 	}
 	return ret;
 }
-- 
1.8.3.2
Previous: Junio C Hamano
Message 3 of 3 in “get_octopus_merge_bases(): cleanup redundant variable”
  1. get_octopus_merge_bases(): cleanup redundant variableVasily Makarov, Jan 3, 2014
  2. Junio C HamanoJan 3, 2014
  3. get_octopus_merge_bases(): cleanup redundant variableVasily Makarov, Jan 3, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.