git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: Elijah Newren <newren@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Beat Bolli <dev+git@drbeat.li>, Pavel Roskin <plroskin@gmail.com>
Subject: Re: [PATCH v4 2/2] format-patch: teach format.notes config option
Date: Mon, 9 Dec 2019 00:24:51 -0800	[thread overview]
Message-ID: <20191209082451.GA57882@generichostname> (raw)
In-Reply-To: <CABPp-BF44+6gvZVNimKf-k7AWbOjw3OK-cJeFunNR96wvZGkcw@mail.gmail.com>

Hi Elijah,

On Sat, Dec 07, 2019 at 11:48:59PM -0800, Elijah Newren wrote:
> > @@ -864,6 +866,22 @@ static int git_format_config(const char *var, const char *value, void *cb)
> >                         from = NULL;
> >                 return 0;
> >         }
> > +       if (!strcmp(var, "format.notes")) {
> > +               struct strbuf buf = STRBUF_INIT;
> > +               int b = git_parse_maybe_bool(value);
> > +               if (!b)
> > +                       return 0;
> > +               rev->show_notes = 1;
> > +               if (b < 0) {
> > +                       strbuf_addstr(&buf, value);
> > +                       expand_notes_ref(&buf);
> > +                       string_list_append(&rev->notes_opt.extra_notes_refs,
> > +                                       strbuf_detach(&buf, NULL));
> > +               } else {
> > +                       rev->notes_opt.use_default_notes = 1;
> > +               }
> > +               return 0;
> > +       }
> 
> What if someone has multiple format.notes entries in their config
> file, but the last entry is "false" -- shouldn't that disable notes?
> Also, what if they specify both "true" and e.g.
> "refs/notes/my-cool-notes"?  In that case, should it show
> refs/notes/my-cool-notes because that's obviously showing some notes
> so it satisfies true as well as the specific request about which note,
> or should it treat "true" the same as the-default-notes-ref and then
> add the two refs together and show them both?

I think I'll just copy the existing logic of --notes, --notes=<ref> and
--no-notes from revision.c to `format.notes = true`, 
`format.notes = <ref>` and `format.notes = false` respectively. IOW,
with `format.notes = true`, we'll unconditionally use the default notes,
with `format.notes = <ref>`, we'll append <ref> to the reflist and with
`format.notes = false`, we'll clear and unset the notes refs.

It seems like that logic has been around for almost a decade and I don't
think anyone's complained about it so I think it should be safe to
duplicate.

> 
> >
> >         return git_log_config(var, value, cb);
> >  }
> > @@ -1617,8 +1635,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
> >         extra_to.strdup_strings = 1;
> >         extra_cc.strdup_strings = 1;
> >         init_log_defaults();
> > -       git_config(git_format_config, NULL);
> >         repo_init_revisions(the_repository, &rev, prefix);
> > +       git_config(git_format_config, &rev);
> 
> Calling git_config() after repo_init_revisions() breaks things;
> generally git_config() should always be called first.  Here,
> git_format_config() can set up parameters used by
> repo_init_revisions(), and by reversing the order of the two you end
> up ignoring settings specified by the user (e.g. diff.context having a
> value of 5).  This came up due to the bug report at
> https://lore.kernel.org/git/xmqqa78d2qmk.fsf@gitster-ct.c.googlers.com/T/#mb6a09958ff10acde295b37a9136bc3791fd4a2c2
> (though fixing the issue there _also_ requires fixing git_am_config()
> to call git_diff_ui_config()).  To break the circular dependency here,
> we'd need to store the information that git_format_config() discovers
> in some data structure besides rev, and then after the
> repo_init_revisions() call has finished then update rev.

I see, I'll move the git_config() back up while I'm at it.

> 
> I was just going to do that, but then ran into the questions above
> about multiple format.notes entries in the config file, and am not as
> sure about what should be done about that stuff (and I don't want to
> try to translate the current behavior as-is while tweaking where the
> stuff is stored, both because I'm not sure of the right behavior and
> because I don't want future folks to blame the code to me when they
> hit bugs in this area), so I'm firing off this email instead.

Sounds good, I don't want my bugs blamed on anyone else either ;)

I'll try to get a patchset out soon and hopefully you'll be able to base
your work off of that.

Thanks,

Denton

> 
> So, um...help?
> 
> Thanks,
> Elijah

      reply	other threads:[~2019-12-09  8:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16 23:13 [PATCH v4 0/2] format-patch: teach format.notes config option Denton Liu
2019-05-16 23:13 ` [PATCH v4 1/2] git-format-patch.txt: document --no-notes option Denton Liu
2019-05-16 23:14 ` [PATCH v4 2/2] format-patch: teach format.notes config option Denton Liu
2019-12-08  7:48   ` Elijah Newren
2019-12-09  8:24     ` Denton Liu [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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191209082451.GA57882@generichostname \
    --to=liu.denton@gmail.com \
    --cc=dev+git@drbeat.li \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newren@gmail.com \
    --cc=plroskin@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).