{"thread":{"id":"24106","subject":"[RFC/PATCH] pretty.c: %S format specifier for source ref","startedAt":"2010-06-14T14:50:05Z","lastAt":"2010-06-14T14:50:05Z","messageCount":1,"participants":["Michael J Gruber"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"143658","messageId":"96891c0177b947c6d737c1f05687b3bd736a502b.1276526878.git.git@drmicha.warpmail.net","threadId":"24106","inReplyTo":null,"subject":"[RFC/PATCH] pretty.c: %S format specifier for source ref","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-06-14T14:50:05Z","receivedAt":"2010-06-14T14:50:05Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Currently, there is no way to combine --source with a format string for\nlog and friends.\n\nIntroduce a %S format specifier which outputs the source ref if --source\nis given also. This is analogous to specfiers like %gs which are empty\nunless used with -g.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nNotes:\n    I'm not sure whether it's worth introducing pretty_ctx.show_source to\n    keep track of the use of --source. commit->util is possibly used by\n    other codepaths also. Even without this patch, --cherry-pick --source\n    does not work (in the sense that there is an empty source output) because\n    of this.\n    \n    RFC obviously also so that I don't have to write doc and tests just yet :)\n\n pretty.c |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 8b18efd..146320f 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -867,6 +867,10 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,\n \tcase 'd':\n \t\tformat_decoration(sb, commit);\n \t\treturn 1;\n+\tcase 'S':\n+\t\tif (/* revs->show_source && */commit->util)\n+\t\t\tstrbuf_addstr(sb, (char *) commit->util);\n+\t\treturn 1;\n \tcase 'g':\t\t/* reflog info */\n \t\tswitch(placeholder[1]) {\n \t\tcase 'd':\t/* reflog selector */\n-- \n1.7.1.511.gfbed4\n"}]}