[PATCH] '%S' option for pretty printing to support --source
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