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

[POC PATCH 4/9] pretty: refactor add_merge_info() into parts

From
Thomas Rast <tr@thomasrast.ch>
Date
Feb 4, 2014, 22:17 UTC
Message-ID
<935d776f5799f1dd9ecc0010059a379dec224172.1391549294.git.tr@thomasrast.ch>
In-Reply-To
<cover.1391549294.git.tr@thomasrast.ch>
pp_commit_list() will be reused later.
Signed-off-by: Thomas Rast <tr@thomasrast.ch>
---
Necessary only for the next patch, which may be of dubious value.
 commit.h |  1 +
 pretty.c | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/commit.h b/commit.h
index 16d9c43..b51817b 100644
--- a/commit.h
+++ b/commit.h
@@ -101,6 +101,7 @@ struct pretty_print_context {
 	struct string_list *mailmap;
 	int color;
 	struct ident_split *from_ident;
+	struct commit_list *merge_bases;
 
 	/*
 	 * Fields below here are manipulated internally by pp_* functions and
diff --git a/pretty.c b/pretty.c
index 87db08b..5e44cf8 100644
--- a/pretty.c
+++ b/pretty.c
@@ -517,6 +517,31 @@ static const char *skip_empty_lines(const char *msg)
 	return msg;
 }
 
+static const char *pp_sha1_to_hex(const struct pretty_print_context *pp,
+				  const unsigned char *sha1)
+{
+	const char *hex = NULL;
+	if (pp->abbrev)
+		hex = find_unique_abbrev(sha1, pp->abbrev);
+	if (!hex)
+		hex = sha1_to_hex(sha1);
+	return hex;
+}
+
+static void pp_commit_list(const struct pretty_print_context *pp,
+			   struct strbuf *sb,
+			   const char *prefix,
+			   const struct commit_list *list)
+{
+	strbuf_addstr(sb, prefix);
+	while (list) {
+		struct commit *commit = list->item;
+		strbuf_addf(sb, " %s", pp_sha1_to_hex(pp, commit->object.sha1));
+		list = list->next;
+	}
+	strbuf_addch(sb, '\n');
+}
+
 static void add_merge_info(const struct pretty_print_context *pp,
 			   struct strbuf *sb, const struct commit *commit)
 {
@@ -526,20 +551,7 @@ static void add_merge_info(const struct pretty_print_context *pp,
 	    !parent || !parent->next)
 		return;
 
-	strbuf_addstr(sb, "Merge:");
-
-	while (parent) {
-		struct commit *p = parent->item;
-		const char *hex = NULL;
-		if (pp->abbrev)
-			hex = find_unique_abbrev(p->object.sha1, pp->abbrev);
-		if (!hex)
-			hex = sha1_to_hex(p->object.sha1);
-		parent = parent->next;
-
-		strbuf_addf(sb, " %s", hex);
-	}
-	strbuf_addch(sb, '\n');
+	pp_commit_list(pp, sb, "Merge:", parent);
 }
 
 static char *get_header(const struct commit *commit, const char *msg,
-- 
1.9.rc2.232.gdd31389
Previous: Thomas RastNext: Thomas Rast
Message 5 of 11 in “remerge diff proof of concept/RFC”
  1. 0/9 remerge diff proof of concept/RFCThomas Rast, Feb 4, 2014
  2. 1/9 merge-recursive: remove dead conditional in update_stages()Thomas Rast, Feb 4, 2014
  3. 2/9 merge-recursive: internal flag to avoid touching the worktreeThomas Rast, Feb 4, 2014
  4. 3/9 merge-recursive: -Xindex-only to leave worktree unchangedThomas Rast, Feb 4, 2014
  5. 4/9 pretty: refactor add_merge_info() into partsThomas Rast, Feb 4, 2014
  6. 5/9 log: add a merge base inspection optionThomas Rast, Feb 4, 2014
  7. 6/9 combine-diff: do not pass revs->dense_combined_merges redundantlyThomas Rast, Feb 4, 2014
  8. 7/9 Fold all merge diff variants into an enumThomas Rast, Feb 4, 2014
  9. 8/9 merge-recursive: allow storing conflict hunks in indexThomas Rast, Feb 4, 2014
  10. 9/9 log --remerge-diff: show what the conflict resolution changedThomas Rast, Feb 4, 2014
  11. Junio C HamanoFeb 4, 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.