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

[PATCH 1/2] log_tree_diff: get rid of code duplication for first_parent_only

From
Sergey Organov <sorganov@gmail.com>
Date
Aug 28, 2020, 11:05 UTC
Message-ID
<20200828110526.21145-2-sorganov@gmail.com>
In-Reply-To
<20200828110526.21145-1-sorganov@gmail.com>

Handle first_parent_only by breaking from generic loop early rather than by duplicating (part of) the loop body.

Signed-off-by: Sergey Organov <sorganov@gmail.com>
---
 log-tree.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 55a68d0c6101..c01932fa72bf 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -922,21 +922,10 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
 			return 0;
 		else if (opt->combine_merges)
 			return do_diff_combined(opt, commit);
-		else if (opt->first_parent_only) {
-			/*
-			 * Generate merge log entry only for the first
-			 * parent, showing summary diff of the others
-			 * we merged _in_.
-			 */
-			parse_commit_or_die(parents->item);
-			diff_tree_oid(get_commit_tree_oid(parents->item),
-				      oid, "", &opt->diffopt);
-			log_tree_diff_flush(opt);
-			return !opt->loginfo;
+		else if (!opt->first_parent_only) {
+			/* If we show multiple diffs, show the parent info */
+			log->parent = parents->item;
 		}
-
-		/* If we show individual diffs, show the parent info */
-		log->parent = parents->item;
 	}
 
 	showed_log = 0;
@@ -952,7 +941,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
 
 		/* Set up the log info for the next parent, if any.. */
 		parents = parents->next;
-		if (!parents)
+		if (!parents || opt->first_parent_only)
 			break;
 		log->parent = parents->item;
 		opt->loginfo = log;
-- 
2.25.1
Previous: Sergey OrganovNext: Sergey Organov
Message 3 of 5 in “log_tree_diff: simplify”
  1. 0/2 log_tree_diff: simplifySergey Organov, Aug 28, 2020
  2. 2/2 log_tree_diff: get rid of extra check for NULLSergey Organov, Aug 28, 2020
  3. 1/2 log_tree_diff: get rid of code duplication for first_parent_onlySergey Organov, Aug 28, 2020
  4. Sergey OrganovSep 4, 2020
  5. Junio C HamanoSep 6, 2020

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.