[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