All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Gilger <heipei@hackvalue.de>
To: Git ML <git@vger.kernel.org>
Cc: Thomas Rast <trast@student.ethz.ch>, Jeff King <peff@peff.net>,
	Junio C Hamano <gitster@pobox.com>,
	Johannes Gilger <heipei@hackvalue.de>
Subject: [PATCH] pretty.c: Don't expand %N without --show-notes
Date: Sat, 10 Apr 2010 09:05:27 +0200	[thread overview]
Message-ID: <1270883127-11488-1-git-send-email-heipei@hackvalue.de> (raw)
In-Reply-To: <201004061127.01471.trast@student.ethz.ch>

The %N placeholder will only work if --show-notes was provided to log.
By not expanding the user is given feedback that he won't be shown any
notes.

Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
---
 Ok, this is another stab. I don't really know whether we want %N to expand to
 an empty string or not expand at all in case of no --show-notes. Obviously
 using 'return 1;' would implement the former behaviour, while I chose the
 latter because it prevents people like me from building useless log aliases.

 Documentation/pretty-formats.txt |    3 ++-
 pretty.c                         |    3 +++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 1686a54..bf7813f 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -143,7 +143,8 @@ 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.
+format if `--decorate` was not already provided on the command line. The %N
+placeholder won't be expanded unless `--show-notes` was provided.
 
 If you add a `{plus}` (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 6ba3da8..b39e2d5 100644
--- a/pretty.c
+++ b/pretty.c
@@ -775,6 +775,9 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
 		}
 		return 0;	/* unknown %g placeholder */
 	case 'N':
+		if (!c->pretty_ctx->show_notes)
+			return 0;
+
 		format_display_notes(commit->object.sha1, sb,
 			    git_log_output_encoding ? git_log_output_encoding
 						    : git_commit_encoding, 0);
-- 
1.7.0.2.201.g80978

  parent reply	other threads:[~2010-04-10  7:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-05 11:55 [PATCH] Initialize notes trees if %N is used and no --show-notes given Johannes Gilger
2010-04-06  5:32 ` Jeff King
2010-04-06  9:27 ` Thomas Rast
2010-04-06 11:19   ` Johannes Gilger
2010-04-06 11:52     ` Thomas Rast
2010-04-06 16:22       ` Jeff King
2010-04-07  6:18       ` Junio C Hamano
2010-04-07  6:36         ` Jeff King
2010-04-10  7:05   ` Johannes Gilger [this message]
2010-04-10 20:00     ` [PATCH] pretty.c: Don't expand %N without --show-notes Junio C Hamano
2010-04-10 21:30       ` [PATCH] Notes: Connect the %N flag to --{show,no}-notes Johannes Gilger
2010-04-10 21:51         ` Junio C Hamano
2010-04-10 22:08           ` Jeff King
2010-04-11 14:54             ` [PATCH] pretty: Initialize notes if %N is used Johannes Gilger
2010-04-12  8:56               ` Jeff King
2010-04-13  8:59                 ` [PATCHv2] " Johannes Gilger
2010-04-13 10:03                   ` Jeff King
2010-04-13 10:36                     ` Johannes Gilger
2010-04-13 10:57                       ` [PATCHv3] " y
2010-04-13 10:57                       ` y
2010-04-13 11:01                       ` Johannes Gilger
2010-04-13 11:07                         ` Jeff King
2010-04-13 11:26                           ` [PATCHv4] " Johannes Gilger
2010-04-13 20:01                             ` Junio C Hamano
2010-04-13 20:31                               ` [PATCHv5] " Johannes Gilger
2010-04-10 22:20           ` [PATCH] Notes: Connect the %N flag to --{show,no}-notes Johannes Gilger

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=1270883127-11488-1-git-send-email-heipei@hackvalue.de \
    --to=heipei@hackvalue.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=trast@student.ethz.ch \
    /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.