From: Harry Jeffery <harry@exec64.co.uk>
To: git@vger.kernel.org
Subject: [PATCH 2/2] pretty: add %D format specifier
Date: Wed, 10 Sep 2014 23:00:15 +0100 [thread overview]
Message-ID: <5410C9EF.9080509@exec64.co.uk> (raw)
In-Reply-To: <5410C998.5060701@exec64.co.uk>
%d prints decorations wrapped by " (" and ")". %D provides the same
output without the parenthesis, making " (%D)" and "%d" equivalent to
one another.
Signed-off-by: Harry Jeffery <harry@exec64.co.uk>
---
Documentation/pretty-formats.txt | 6 ++++--
pretty.c | 4 ++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Documentation/pretty-formats.txt
b/Documentation/pretty-formats.txt
index eac7909..2632e1a 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -128,6 +128,7 @@ The placeholders are:
- '%ct': committer date, UNIX timestamp
- '%ci': committer date, ISO 8601 format
- '%d': ref names, like the --decorate option of linkgit:git-log[1]
+- '%D': ref names without the " (", ")" wrapping.
- '%e': encoding
- '%s': subject
- '%f': sanitized subject line, suitable for a filename
@@ -182,8 +183,9 @@ The placeholders are:
NOTE: Some placeholders may depend on other options given to the
revision traversal engine. For example, the `%g*` reflog options will
insert an empty string unless we are traversing reflog entries (e.g., by
-`git log -g`). The `%d` placeholder will use the "short" decoration
-format if `--decorate` was not already provided on the command line.
+`git log -g`). The `%d` and `%D` placeholders will use the "short"
+decoration format if `--decorate` was not already provided on the command
+line.
If you add a `+` (plus sign) after '%' of a placeholder, a line-feed
is inserted immediately before the expansion if and only if the
diff --git a/pretty.c b/pretty.c
index e4dc093..a75ad0d 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1197,6 +1197,10 @@ static size_t format_commit_one(struct strbuf
*sb, /* in UTF-8 */
load_ref_decorations(DECORATE_SHORT_REFS);
format_decorations(sb, commit, c->auto_color, " (", ", ", ")");
return 1;
+ case 'D':
+ load_ref_decorations(DECORATE_SHORT_REFS);
+ format_decorations(sb, commit, c->auto_color, "", ", ", "");
+ return 1;
case 'g': /* reflog info */
switch(placeholder[1]) {
case 'd': /* reflog selector */
--
2.1.0
next prev parent reply other threads:[~2014-09-10 22:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 21:58 [PATCH 1/2] log-tree: make format_decorations more flexible Harry Jeffery
2014-09-10 22:00 ` Harry Jeffery [this message]
2014-09-11 16:56 ` [PATCH 2/2] pretty: add %D format specifier Junio C Hamano
2014-09-11 17:26 ` Harry Jeffery
2014-09-11 19:42 ` Junio C Hamano
2014-09-11 22:39 ` [PATCH 1/2] log-tree: make format_decorations more flexible Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5410C9EF.9080509@exec64.co.uk \
--to=harry@exec64.co.uk \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.