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

[PATCH] '%S' option for pretty printing to support --source

From
PHPetri Hodju <petri.hodju@yumesystems.com>
Date
Mar 5, 2009, 07:18 UTC
Message-ID
<200903050918.29051.petri.hodju@yumesystems.com>
From 79f817e25aada377ccb40ebf76c29af7f21e1ec4 Mon Sep 17 00:00:00 2001
From: Petri Hodju <petrihodju@yahoo.com>
Date: Thu, 5 Mar 2009 09:00:39 +0200
Subject: [PATCH] '%S' option for pretty printing to support --source
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Print out the ref name by which each commit was reached. Works only when --source option is used
Examples:
git-log --graph --pretty=format:"%h(%S) — %s (%cr)" --abbrev-commit --date=relative --source
Show ref by which each commit is reachable in current branch
git-log --graph --pretty=format:"%h(%S) — %s (%cr)" --abbrev-commit --date=relative --source --all
Show ref by which each commit is reachable globally
Signed-off-by: Petri Hodju <petrihodju@yahoo.com>
---
 pretty.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/pretty.c b/pretty.c
index 6cd9149..cf05b37 100644
--- a/pretty.c
+++ b/pretty.c
@@ -544,6 +544,12 @@ static void format_decoration(struct strbuf *sb, const struct commit *commit)
 		strbuf_addch(sb, ')');
 }
 
+static void format_source(struct strbuf *sb, const struct commit *commit)
+{
+    if (commit->util)
+	strbuf_addstr(sb, (char *) commit->util);
+}
+
 static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
                                void *context)
 {
@@ -650,6 +656,9 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
 	case 'd':
 		format_decoration(sb, commit);
 		return 1;
+	case 'S':
+		format_source(sb, commit);
+		return 1;
 	}
 
 	/* For the rest we have to parse the commit header. */
-- 
1.6.2.rc2.22.g1d035.dirty
Next: Jeff King
Message 1 of 5 in “'%S' option for pretty printing to support --source”
  1. '%S' option for pretty printing to support --sourcePetri Hodju, Mar 5, 2009
  2. Jeff KingMar 5, 2009
  3. Johannes SchindelinMar 5, 2009
  4. Deskin MillerMar 5, 2009
  5. Jeff KingMar 6, 2009

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.