Re: [PATCH v2 2/3] notes.c: fixed tip when target and append note are both empty
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Nov 7, 2022, 14:40 UTC
- Message-ID
- <221107.86cz9yx1wh.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <5dbe014a09cca6ffa01dc9f61d0ddc095d31d518.1667828335.git.dyroneteng@gmail.com>
On Mon, Nov 07 2022, Teng Long wrote:
Show 34 quoted lines
> From: Teng Long <dyroneteng@gmail.com>
>
> When "git notes append <object>" is executed, if there is no note in
> the given object and the appended note is empty, the command line
> prompt will be as follows:
>
> "Removing note for object <object>"
>
> Actually, this tip is not that accurate, because there is no note in
> the original <object>, and it also does no remove work on the notes
> reference, so let's fix this and give the correct tip.
>
> Signed-off-by: Teng Long <dyroneteng@gmail.com>
> ---
> builtin/notes.c | 17 ++++++++++++++---
> t/t3301-notes.sh | 3 ++-
> 2 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/notes.c b/builtin/notes.c
> index f0fa337e8c..02b88e54d8 100644
> --- a/builtin/notes.c
> +++ b/builtin/notes.c
> @@ -567,9 +567,15 @@ static int append_edit(int argc, const char **argv, const char *prefix)
> struct notes_tree *t;
> struct object_id object, new_note;
> const struct object_id *note;
> - char *logmsg;
> + char *logmsg = NULL;
> const char * const *usage;
> - struct note_data d = { 0, 0, NULL, STRBUF_INIT };
> + struct note_data d = {
> + .given = 0,
> + .use_editor = 0,
> + .edit_path = NULL,Most of this is an unrelated "use designated init" cleanup, which is good, but let's do that in a different commit if we need it. And then you can drop all of these...
> + .buf = STRBUF_INIT
...and only need to keep this one.