Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH 2/2] pretty=format: Add %d to show decoration
Date: Mon, 7 Apr 2008 14:41:12 +0100 (BST)	[thread overview]
Message-ID: <alpine.DEB.1.00.0804071441040.430@eeepc-johanness> (raw)
In-Reply-To: <alpine.DEB.1.00.0804071439480.430@eeepc-johanness>


With this patch, "git log --decorate --pretty=format:%d", shows the
name decoration (i.e. whenever a commit matches a ref, that ref's name
is shown).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	Maybe %d should expand to " (<name decoration>)" instead of
	"<name decoration>"?

 Documentation/pretty-formats.txt |    1 +
 pretty.c                         |    9 +++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index e8bea3e..9d8a8d4 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -117,6 +117,7 @@ The placeholders are:
 - '%e': encoding
 - '%s': subject
 - '%b': body
+- '%d': decoration (needs --decorate)
 - '%Cred': switch color to red
 - '%Cgreen': switch color to green
 - '%Cblue': switch color to blue
diff --git a/pretty.c b/pretty.c
index 6c04176..37f7c3e 100644
--- a/pretty.c
+++ b/pretty.c
@@ -489,6 +489,15 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
 			return 3;
 		} else
 			return 0;
+	case 'd':
+		{
+			struct name_decoration *decoration =
+				lookup_decoration(&name_decoration,
+				&commit->object);
+			if (decoration)
+				strbuf_addstr(sb, decoration->name);
+			return 1;
+		}
 	}
 
 	/* these depend on the commit */
-- 
1.5.5.rc0.208.g1d50

  reply	other threads:[~2008-04-07 13:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-07 13:40 [PATCH 1/2] decorate: use "const struct object" Johannes Schindelin
2008-04-07 13:41 ` Johannes Schindelin [this message]
2008-04-09 21:40   ` [PATCH 2/2] pretty=format: Add %d to show decoration René Scharfe
2008-04-10  8:39   ` 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=alpine.DEB.1.00.0804071441040.430@eeepc-johanness \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox