[PATCH 1/2] pretty.c: add %% format specifier
- From
- Pieter de Bie <pdebie@ai.rug.nl>
- Date
- Sep 7, 2008, 23:05 UTC
- Message-ID
- <1220828741-91050-1-git-send-email-pdebie@ai.rug.nl>
- In-Reply-To
- <7vd4jgpkce.fsf@gitster.siamese.dyndns.org>
This adds a %% format which just prints a literal %
Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl> ---
On 7 sep 2008, at 07:59, Junio C Hamano wrote:
Show 6 quoted lines
>Junio C Hamano <gitster@pobox.com> writes: >>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