[PATCH 1/2] pretty.c: add %% format specifier
From: Pieter de Bie <hidden>
Date: 2016-06-15 22:45:19
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
This adds a %% format which just prints a literal % Signed-off-by: Pieter de Bie <redacted> --- On 7 sep 2008, at 07:59, Junio C Hamano wrote:
Junio C Hamano [off-list ref] writes:quoted
I somehow suspect it might be much simpler, more contained and robust if you:Ah, that would not work, sorry, because this if() statement is only about an uninteresting case of --allow-empty. You need to do this the hard way and teach get_commit_format_string() quote % characters in branch names.
Yes, here is patch for this. Sorry for the style issues. I also fixed the strbuf issue. Documentation/pretty-formats.txt | 1 + pretty.c | 3 +++ 2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index f18d33e..b91db86 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt@@ -127,6 +127,7 @@ The placeholders are: - '%m': left, right or boundary mark - '%n': newline - '%x00': print a byte from a hex code +- '%%': print a literal '%' * 'tformat:' +
diff --git a/pretty.c b/pretty.c
index 8beafa0..f66d687 100644
--- a/pretty.c
+++ b/pretty.c@@ -538,6 +538,9 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder, return 3; } else return 0; + case '%': + strbuf_addch(sb, '%'); + return 1; } /* these depend on the commit */
--
1.6.0.1.346.g880d9.dirty