From: David Disseldorp <ddiss@suse.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Teng Long <dyroneteng@gmail.com>
Subject: Re: [PATCH 2/2] notes: revert note_data.given behavior with empty notes add
Date: Fri, 26 Jul 2024 01:26:04 +0200 [thread overview]
Message-ID: <20240726012604.057a645a.ddiss@suse.de> (raw)
In-Reply-To: <xmqqzfq5flfd.fsf@gitster.g>
On Thu, 25 Jul 2024 10:09:26 -0700, Junio C Hamano wrote:
> David Disseldorp <ddiss@suse.de> writes:
>
> > Subject: Re: [PATCH 2/2] notes: revert note_data.given behavior with empty notes add
>
> Maybe it is just me, but "revert" has a specific connotation in the
> context of the command this project develops, and when your patch is
> not doing so, it gets misleading. If you said you are restoring the
> behaviour, that would be more easily understood.
>
> notes: do not trigger editor when adding an empty note
>
> perhaps?
Sure, sounds good to me.
> > Prior to 90bc19b3ae, note_data.given was set alongside an -m, -C or -F
>
> Please make the first mention of a commit using "git show -s --pretty=reference"
> format, i.e.
>
> 90bc19b3ae (notes.c: introduce '--separator=<paragraph-break>' option, 2023-05-27)
>
> Using the reference format, besides being consistent, is very much
> preferrable to allow us to tell how old the problem goes back
> immediately by having the datestamp at the end.
Ack, will do.
> more generally, this proposed log message starts with implementation
> details. When we have a user-visible breakage, please start from
> describing that instead. The usual way to compose a log message of
> this project is to
>
> - Give an observation on how the current system work in the present
> tense (so no need to say "Currently X is Y", just "X is Y" or "X
> does Y"), and discuss what you perceive as a problem in it.
>
> - Propose a solution (optional---often, problem description
> trivially leads to an obvious solution in reader's minds).
>
> - Give commands to the codebase to "become like so".
>
> in this order. So something along this line:
>
> With "git notes add -C $blob", the given blob contents are
> to be made into a note without involving an editor. But
> when "--allow-empty" is given, the editor is invoked.
>
> This behaviour started when 90bc19b3 (notes.c: introduce
> '--separator=<paragraph-break>' option, 2023-05-27). Prior
> to that commit, we used to do this and that ... describe
> implementation details here if you want ...
>
> Restore the original behaviour of "git note" that takes the
> contents given via the "-m", "-C", "-F" options without
> invoking an editor, by doing ... this and that ... describe
> implementation details here if you want ...
>
> would be more customary.
>
> This is not a fault of this patch, and certainly not a fault of
> 90bc19b3 (notes.c: introduce '--separator=<paragraph-break>' option,
> 2023-05-27), but unlike "git commit" and "git tag" that can take
> pre-prepared contents from some source and by default use that
> intact without involving an editor, "git notes" seems to lack the
> ability to countermand this default and spawn an editor (e.g., "git
> commit -F myfile -e"). We may want to #leftoverbits fix that.
>
> > Fixes: 90bc19b3ae ("notes.c: introduce '--separator=<paragraph-break>' option")
> > Link: https://github.com/ddiss/icyci/issues/12
>
> We generally refrain from using these two trailers. Please drop them.
>
> Especially "Fixes" claim can later prove incorrect (we thought this
> was a good fix when committing, but it later turned out to be a bad
> one), and besides you will be referring to the problematic commit in
> your proposed log message already anyway.
Okay, will drop the Fixes: and go with a footnote for the downstream
issue, as proposed by Kristoffer.
> > Signed-off-by: David Disseldorp <ddiss@suse.de>
> > ---
> > builtin/notes.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/builtin/notes.c b/builtin/notes.c
> > index d9c356e354..3ccb3eb602 100644
> > --- a/builtin/notes.c
> > +++ b/builtin/notes.c
> > @@ -282,6 +282,7 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
> > ALLOC_GROW_BY(d->messages, d->msg_nr, 1, d->msg_alloc);
> > d->messages[d->msg_nr - 1] = msg;
> > msg->stripspace = STRIPSPACE;
> > + d->given = 1;
> > return 0;
> > }
> >
> > @@ -302,6 +303,7 @@ static int parse_file_arg(const struct option *opt, const char *arg, int unset)
> > ALLOC_GROW_BY(d->messages, d->msg_nr, 1, d->msg_alloc);
> > d->messages[d->msg_nr - 1] = msg;
> > msg->stripspace = STRIPSPACE;
> > + d->given = 1;
> > return 0;
> > }
> >
> > @@ -335,6 +337,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
> > ALLOC_GROW_BY(d->messages, d->msg_nr, 1, d->msg_alloc);
> > d->messages[d->msg_nr - 1] = msg;
> > msg->stripspace = NO_STRIPSPACE;
> > + d->given = 1;
> > return 0;
> > }
>
> All the above places that resurrects setting d.given looks OK, but
> it makes me wonder if you need to add them in the first place.
>
> Wouldn't it be sufficient to see if d->msg_nr is non-zero after all
> the parsing is done? If any of the message came from "-c", a
> separate flag d->use_editor is set to force you run the editor, and
> otherwise you'd not be using the editor, right?
>
> > @@ -515,7 +518,6 @@ static int add(int argc, const char **argv, const char *prefix)
> >
> > if (d.msg_nr)
> > concat_messages(&d);
> > - d.given = !!d.buf.len;
>
> Here is what I mean. If you didn't do any of the "d->given = 1"
> above during parsing, and instead say
>
> if (d.msg_nr)
> concat_messages(&d);
> d.given = d.msg_nr;
>
> shouldn't it be sufficient to convince prepare_note_data() to do the
> right thing?
Yes, I also noticed that msg_nr could also be used for this, but chose
to revert back to the old given logic for clarity. I'll revisit the
msg_nr approach for v2.
Thanks for the feedback,
David
prev parent reply other threads:[~2024-07-25 23:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 14:41 [PATCH 0/2] notes: fix editor invocation regression David Disseldorp
2024-07-25 14:41 ` [PATCH 1/2] t3301-notes: check editor isn't invoked for empty notes add David Disseldorp
2024-07-25 15:52 ` Kristoffer Haugsbakk
2024-07-25 16:03 ` David Disseldorp
2024-07-25 17:10 ` Junio C Hamano
2024-07-25 16:31 ` Junio C Hamano
2024-07-25 23:10 ` David Disseldorp
2024-07-25 14:41 ` [PATCH 2/2] notes: revert note_data.given behavior with " David Disseldorp
2024-07-25 17:09 ` Junio C Hamano
2024-07-25 17:22 ` Kristoffer Haugsbakk
2024-07-25 23:26 ` David Disseldorp [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=20240726012604.057a645a.ddiss@suse.de \
--to=ddiss@suse.de \
--cc=dyroneteng@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox