git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Jan Krüger" <jk@jk.gs>,
	git@vger.kernel.org, "Randal L. Schwartz" <merlyn@stonehenge.com>,
	"Thomas Rast" <trast@student.ethz.ch>,
	"Andreas Schwab" <schwab@linux-m68k.org>
Subject: Re: [PATCH] log-tree: use custom line terminator in line termination mode
Date: Tue, 01 May 2012 09:12:10 -0700	[thread overview]
Message-ID: <7v1un3c23p.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20120501085649.GD4998@sigill.intra.peff.net> (Jeff King's message of "Tue, 1 May 2012 04:56:49 -0400")

Jeff King <peff@peff.net> writes:

> On Mon, Apr 30, 2012 at 12:36:07PM -0700, Junio C Hamano wrote:
>
>> Jan Krüger <jk@jk.gs> writes:
>> 
>> > When using a custom format in line termination mode (as opposed to line
>> > separation mode), the configured line terminator is not used, so things
>> > like "git log --pretty=tformat:%H -z" do not work properly.
>> >
>> > Make it use the line terminator the user ordered.
>> >
>> > Signed-off-by: Jan Krüger <jk@jk.gs>
>> > ---
>> >  log-tree.c |    2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/log-tree.c b/log-tree.c
>> > index 34c49e7..44f0268 100644
>> > --- a/log-tree.c
>> > +++ b/log-tree.c
>> > @@ -682,7 +682,7 @@ void show_log(struct rev_info *opt)
>> >  	if (opt->use_terminator) {
>> >  		if (!opt->missing_newline)
>> >  			graph_show_padding(opt->graph);
>> > -		putchar('\n');
>> > +		putchar(opt->diffopt.line_termination);
>> >  	}
>> >  
>> >  	strbuf_release(&msgbuf);
>> 
>> Looks sensible.  Perhaps we would want to add a test?
>
> Hmm. This came up before, and the issue is (or can be) slightly more
> complex:
>
>   http://thread.gmane.org/gmane.comp.version-control.git/122478/focus=122568

Yeah, the test given completely forgets about "log -p" case, as you said
in the above:

    But we can't just modify that to use the specified line terminator,
    because sometimes it is acting as a separator between commit message and
    diff, and sometimes it is acting as the terminator of the whole record.

So the patch is not quite right for the "log -p -z" (or "log --stat -z")
case.

The correct output would have NUL after each commit, so "-z --format=%s"
would have a single-liner subject with the line-terminating LF replaced
with NUL, and "-p/--stat -z --format=%s" would have a single-liner subject
with its line-terminating LF, followed by the diff/diffstat in which the
terminating LF of the last line is replaced with NUL, but to be consistent
with what "-p/--stat -z --pretty=format:%s" does, I think it is OK to
append NUL to the diff/diffstat part instead of replacing its last LF with
NUL.

  reply	other threads:[~2012-05-01 16:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-30 17:58 git log -z still outputting newlines? Randal L. Schwartz
2012-04-30 18:34 ` Andreas Schwab
2012-04-30 19:02   ` Thomas Rast
2012-04-30 18:45 ` [PATCH] log-tree: use custom line terminator in line termination mode Jan Krüger
2012-04-30 19:36   ` Junio C Hamano
2012-04-30 20:28     ` [PATCH v2] " Jan Krüger
2012-04-30 22:58       ` Junio C Hamano
2012-04-30 23:28         ` Jan Krüger
2012-05-01  0:28         ` Andreas Schwab
2012-05-01  0:43           ` Junio C Hamano
2012-05-01  7:29             ` Andreas Schwab
2012-05-01  2:51         ` Randal L. Schwartz
2012-05-01  4:27           ` Junio C Hamano
2012-05-01  8:56     ` [PATCH] " Jeff King
2012-05-01 16:12       ` Junio C Hamano [this message]
2012-05-01 17:06         ` Junio C Hamano
2012-05-01 20:03           ` 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=7v1un3c23p.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jk@jk.gs \
    --cc=merlyn@stonehenge.com \
    --cc=peff@peff.net \
    --cc=schwab@linux-m68k.org \
    --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 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).