git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Joey Hess <joey@kitenet.net>, git@vger.kernel.org
Subject: Re: git notes: notes
Date: Wed, 20 Jan 2010 16:31:38 -0500	[thread overview]
Message-ID: <20100120213137.GA9107@coredump.intra.peff.net> (raw)
In-Reply-To: <7viqaw1ohx.fsf@alter.siamese.dyndns.org>

On Wed, Jan 20, 2010 at 12:59:38PM -0800, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > Is splitting on blank lines an error? I don't think so. The original
> > format was never strictly defined, but given the --pretty=raw format, it
> > seems like a fairly obvious thing to do.
> >
> > I am inclined to cut the notes output from --pretty=raw, and let callers
> > ask for them explicitly with --show-notes or something similar. We can
> > leave them on by default in the "normal" output. This will still break
> > scripts doing "git log | ./script", but I don't think we have ever
> > condoned that practice.
> 
> Sounds like a plan.

We can start with this patch, which clears up Joey's problem.

-- >8 --
Subject: [PATCH] don't show notes for --pretty=raw

The --pretty=raw format of the log family is likely to be
used by scripts. Such scripts may parse the output into
records on blank lines, since doing so in the past has
always worked. However, with the recently added notes
output, such parsers will see an extra stanza for any
commits that have notes.

This patch turns off the notes output for the raw format to
avoid breaking such scripts.

Signed-off-by: Jeff King <peff@peff.net>
---
 pretty.c         |    2 +-
 t/t3301-notes.sh |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/pretty.c b/pretty.c
index 9001379..0674027 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1094,7 +1094,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
 	if (fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body)
 		strbuf_addch(sb, '\n');
 
-	if (fmt != CMIT_FMT_ONELINE)
+	if (fmt != CMIT_FMT_ONELINE && fmt != CMIT_FMT_RAW)
 		get_commit_notes(commit, sb, encoding,
 				 NOTES_SHOW_HEADER | NOTES_INDENT);
 
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 1e34f48..4c3de9d 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -147,4 +147,18 @@ test_expect_success 'show -m and -F notes' '
 	test_cmp expect-m-and-F output
 '
 
+cat >expect << EOF
+commit 15023535574ded8b1a89052b32673f84cf9582b8
+tree e070e3af51011e47b183c33adf9736736a525709
+parent 1584215f1d29c65e99c6c6848626553fdd07fd75
+author A U Thor <author@example.com> 1112912173 -0700
+committer C O Mitter <committer@example.com> 1112912173 -0700
+
+    4th
+EOF
+test_expect_success 'git log --pretty=raw does not show notes' '
+	git log -1 --pretty=raw >output &&
+	test_cmp expect output
+'
+
 test_done
-- 
1.6.6.510.g159cf

  reply	other threads:[~2010-01-20 21:31 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-20  5:03 git notes: notes Joey Hess
2010-01-20  9:48 ` Thomas Rast
2010-01-20 18:14   ` Joey Hess
2010-01-20 10:48 ` Johan Herland
2010-01-20 18:24   ` Joey Hess
2010-01-20 19:30     ` Junio C Hamano
2010-01-20 19:56       ` Joey Hess
2010-01-20 20:10         ` Junio C Hamano
2010-01-20 20:36           ` Joey Hess
2010-01-20 20:54             ` Jeff King
2010-01-20 20:59               ` Junio C Hamano
2010-01-20 21:31                 ` Jeff King [this message]
2010-01-20 21:41                   ` Jeff King
2010-01-20 22:07                     ` Junio C Hamano
2010-01-20 22:21                       ` Jeff King
2010-01-20 21:02           ` Michael J Gruber
2010-01-20 21:08             ` Junio C Hamano
2010-01-20 21:36               ` Jeff King
2010-01-20 21:59               ` Junio C Hamano
2010-01-20 22:25                 ` Jeff King
2010-01-20 22:33                   ` Junio C Hamano
2010-01-20 22:58                 ` Johannes Schindelin
2010-01-20 23:06                   ` Jeff King
2010-01-20 23:14                   ` Junio C Hamano
2010-01-21  2:54                     ` Johan Herland
2010-01-21  3:03                       ` Junio C Hamano
2010-01-21  3:37                     ` Junio C Hamano
2010-01-21  8:45               ` Michael J Gruber
2010-01-24 14:20               ` Matthieu Moy
2010-01-24 14:27                 ` Sverre Rabbelier
2010-01-21  2:05     ` Johan Herland
2010-01-21  3:59       ` Johannes Schindelin
2010-01-21  4:05         ` Joey Hess
2010-01-27 11:55           ` Johan Herland
2010-01-25 18:08       ` John Koleszar
2010-01-27 20:01         ` Christian Couder

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=20100120213137.GA9107@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=joey@kitenet.net \
    /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;
as well as URLs for NNTP newsgroup(s).