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

[PATCH] log and rev-list: don't print extra prefixes already shown in the graph

From
Adam Simpkins <adam@adamsimpkins.net>
Date
May 25, 2008, 07:07 UTC
Message-ID
<1211699241-19201-1-git-send-email-adam@adamsimpkins.net>
In-Reply-To
<20080525064324.GA16827@adamsimpkins.net>

With the --graph option, the graph already outputs 'o' instead of '*' for boundary commits, and '<' or '>' when --left-right is specified. The extra -/</> prefix in front of the commit itself isn't needed.

(This change also disables the '^' prefix for UNINTERESTING commits. The graph code currently doesn't print anything special for these commits, since it assumes no UNINTERESTING, non-BOUNDARY commits are displayed. This is potentially a bug if UNINTERESTING non-BOUNDARY commits can actually be displayed via some code path.)

Signed-off-by: Adam Simpkins <adam@adamsimpkins.net>
---

Here's simple patch to remove the redundant </>/- prefix in the log message. As the commit message mentions, I'm not sure if it's doing the right thing with respect to UNINTERESTING commits, though.

 builtin-rev-list.c |   21 ++++++++++++---------
 log-tree.c         |   41 +++++++++++++++++++++++------------------
 2 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 54d55cc..b474527 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -65,15 +65,18 @@ static void show_commit(struct commit *commit)
 		printf("%lu ", commit->date);
 	if (header_prefix)
 		fputs(header_prefix, stdout);
-	if (commit->object.flags & BOUNDARY)
-		putchar('-');
-	else if (commit->object.flags & UNINTERESTING)
-		putchar('^');
-	else if (revs.left_right) {
-		if (commit->object.flags & SYMMETRIC_LEFT)
-			putchar('<');
-		else
-			putchar('>');
+
+	if (!revs.graph) {
+		if (commit->object.flags & BOUNDARY)
+			putchar('-');
+		else if (commit->object.flags & UNINTERESTING)
+			putchar('^');
+		else if (revs.left_right) {
+			if (commit->object.flags & SYMMETRIC_LEFT)
+				putchar('<');
+			else
+				putchar('>');
+		}
 	}
 	if (revs.abbrev_commit && revs.abbrev)
 		fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
diff --git a/log-tree.c b/log-tree.c
index 1474d1f..5505606 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -228,15 +228,17 @@ void show_log(struct rev_info *opt)
 	if (!opt->verbose_header) {
 		graph_show_commit(opt->graph);
 
-		if (commit->object.flags & BOUNDARY)
-			putchar('-');
-		else if (commit->object.flags & UNINTERESTING)
-			putchar('^');
-		else if (opt->left_right) {
-			if (commit->object.flags & SYMMETRIC_LEFT)
-				putchar('<');
-			else
-				putchar('>');
+		if (!opt->graph) {
+			if (commit->object.flags & BOUNDARY)
+				putchar('-');
+			else if (commit->object.flags & UNINTERESTING)
+				putchar('^');
+			else if (opt->left_right) {
+				if (commit->object.flags & SYMMETRIC_LEFT)
+					putchar('<');
+				else
+					putchar('>');
+			}
 		}
 		fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
 		if (opt->print_parents)
@@ -293,15 +295,18 @@ void show_log(struct rev_info *opt)
 		fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
 		if (opt->commit_format != CMIT_FMT_ONELINE)
 			fputs("commit ", stdout);
-		if (commit->object.flags & BOUNDARY)
-			putchar('-');
-		else if (commit->object.flags & UNINTERESTING)
-			putchar('^');
-		else if (opt->left_right) {
-			if (commit->object.flags & SYMMETRIC_LEFT)
-				putchar('<');
-			else
-				putchar('>');
+
+		if (!opt->graph) {
+			if (commit->object.flags & BOUNDARY)
+				putchar('-');
+			else if (commit->object.flags & UNINTERESTING)
+				putchar('^');
+			else if (opt->left_right) {
+				if (commit->object.flags & SYMMETRIC_LEFT)
+					putchar('<');
+				else
+					putchar('>');
+			}
 		}
 		fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
 		      stdout);
-- 
1.5.5.1.383.g8c56f.dirty
Previous: Adam Simpkins
Message 6 of 6 in “log --graph: draw '>' and '<' with --left-right”
  1. log --graph: draw '>' and '<' with --left-rightJohannes Schindelin, May 22, 2008
  2. Johannes SchindelinMay 22, 2008
  3. Sverre RabbelierMay 22, 2008
  4. Junio C HamanoMay 25, 2008
  5. Adam SimpkinsMay 25, 2008
  6. log and rev-list: don't print extra prefixes already shown in the graphAdam Simpkins, May 25, 2008

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.