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

[RFC/PATCH] pretty.c: %S format specifier for source ref

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jun 14, 2010, 14:50 UTC
Message-ID
<96891c0177b947c6d737c1f05687b3bd736a502b.1276526878.git.git@drmicha.warpmail.net>

Currently, there is no way to combine --source with a format string for log and friends.

Introduce a %S format specifier which outputs the source ref if --source is given also. This is analogous to specfiers like %gs which are empty unless used with -g.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
Notes:
    I'm not sure whether it's worth introducing pretty_ctx.show_source to
    keep track of the use of --source. commit->util is possibly used by
    other codepaths also. Even without this patch, --cherry-pick --source
    does not work (in the sense that there is an empty source output) because
    of this.
    
    RFC obviously also so that I don't have to write doc and tests just yet :)
 pretty.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/pretty.c b/pretty.c
index 8b18efd..146320f 100644
--- a/pretty.c
+++ b/pretty.c
@@ -867,6 +867,10 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
 	case 'd':
 		format_decoration(sb, commit);
 		return 1;
+	case 'S':
+		if (/* revs->show_source && */commit->util)
+			strbuf_addstr(sb, (char *) commit->util);
+		return 1;
 	case 'g':		/* reflog info */
 		switch(placeholder[1]) {
 		case 'd':	/* reflog selector */
-- 
1.7.1.511.gfbed4
Message 1 of 1 in “pretty.c: %S format specifier for source ref”
  1. pretty.c: %S format specifier for source refMichael J Gruber, Jun 14, 2010

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.