git.vger.kernel.org archive mirror
 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>
Subject: Re: [PATCH] Notes: Connect the %N flag to --{show,no}-notes
Date: Sun, 11 Apr 2010 00:20:31 +0200	[thread overview]
Message-ID: <20100410222031.GA12507@dualtron.lan> (raw)
In-Reply-To: <7v1venvuv8.fsf@alter.siamese.dyndns.org>

On 10/04/10 14:51, Junio C Hamano wrote:
> > -	if (!rev->show_notes_given && !rev->pretty_given)
> > +	if (!rev->show_notes_given)
> >  		rev->show_notes = 1;
> 
> I am puzzled by this change and its possible interaction with codepaths
> that do not have anything to do with %N.  When there is no show-notes and
> an explicit --pretty, we do not want to have rev->show_notes set.
> 
> Admittedly, the real end result we want to see in such a case is just that
> notes are not shown (and rev->show_notes being false is one natural way to
> achieve that), and if ...
Yes, it might seem a little dirty looking at the name of the flags. If
no --show-notes was given and --pretty was supplied, rev->show_notes
should have a value of 'maybe' ;)

I was aiming for minimally invasive changes while keeping the former
behaviour and only dealing with the "only %N" case, which is what this
patch does.

> > -	if (rev->show_notes)
> > +	if (rev->show_notes && (!rev->pretty_given || rev->show_notes_given))
> >  		init_display_notes(&rev->notes_opt);
> 
> ... this change is about ensuring the same outcome by not initializing the
> notes tree, that may work, but it somehow feels iffy.  It would leave some
> codepaths (and another one you just added, I think, with the other hunk in
> this patch) that say "do this only when rev->show_notes is set" and some
> other codepaths that say "unconditionally try to show notes and rely on
> the caller not have initialized the notes tree when it is not wanted."  Is
> that what is going on?
The implicit initialization of the notes_trees only happens if --pretty
is used alone, and in no other case. I was under the impression that not
initializing the notes_trees if one isn't sure of it's use was meant to
be a performance criterion. While --show-notes will always use the notes
when using plain log/show, it won't necessarily use the notes for
certain --pretty/--format formats. Granted, right now I can use --pretty
and --show-notes although I don't use %N and intentionally waste memory
by initializing the trees.

> Unfortunately I don't think of a better and cleaner solution offhand
> (perhaps such a cleaner solution would involve adding a bit more state in
> the rev structure, but I haven't thought things through).
Yes, I came across that structure too but was happy enough my patch
works as it is. I'll leave design decisions up to more involved
contributors, my main agenda is simply to not have git segfault with
something as harmless as "git log '%N'" ;)

Greetings,
Jojo

-- 
Johannes Gilger <heipei@hackvalue.de>
http://heipei.net
GPG-Key: 0xD47A7FFC
GPG-Fingerprint: 5441 D425 6D4A BD33 B580  618C 3CDC C4D0 D47A 7FFC

      parent reply	other threads:[~2010-04-10 22:20 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   ` [PATCH] pretty.c: Don't expand %N without --show-notes Johannes Gilger
2010-04-10 20:00     ` 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           ` Johannes Gilger [this message]

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=20100410222031.GA12507@dualtron.lan \
    --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 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).