Re: [PATCH v4 2/2] format-patch: teach format.notes config option
- From
Denton Liu <liu.denton@gmail.com>
- Date
- Dec 9, 2019, 08:24 UTC
- Message-ID
- <20191209082451.GA57882@generichostname>
- 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:
Show 29 quoted lines
> > @@ -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.
Show 24 quoted lines
> > > > > 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.
Show 8 quoted lines
> > 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
Show 5 quoted lines
> > So, um...help? > > Thanks, > Elijah