git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv3 3/5] builtin/notes: Add --allow-empty, to allow storing empty notes

From
Johan Herland <johan@herland.net>
Date
Nov 9, 2014, 12:31 UTC
Message-ID
<CALKQrgdFDHUc8JzH3XnwvnHdEZOhUN=EmrWXKKDLd+6MG7jMKw@mail.gmail.com>
In-Reply-To
<xmqq1tpehopp.fsf@gitster.dls.corp.google.com>
On Fri, Nov 7, 2014 at 7:04 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Johan Herland <johan@herland.net> writes:
[...]
Show 37 quoted lines
> Assuming that it is a good idea to "allow" empty notes, I think
> there are two issues involved here:
>
>  * Traditionally, feeding an empty note is taken as a request to
>    remove an existing note.  Therefore, there is no way to
>    explicitly ask an empty note to be stored for a commit.
>
>  * Because feeding an empty note was the way to request removal,
>    even though "git notes remove" is there, it is underused.
>
> In other words, assuming that it is a good idea to allow empty
> notes, isn't the desired endgame, after compatibility transition
> period, that "git notes add" will never remove notes?
>
> With that endgame in mind, shouldn't the internal implementation be
> moving in a direction where "create_note()" will *not* be doing any
> removal, and its caller (i.e. "add") does the switching depending on
> the "do we take emptyness as a request to remove"?  I.e.
>
>          static int add(...)
>          {
>                 if (!allow_empty && message_is_empty())
>                         remove_note();
>                 else
>                         create_note();
>         }
>
>>  static void create_note(const unsigned char *object, struct msg_arg *msg,
>> -                     int append_only, const unsigned char *prev,
>> -                     unsigned char *result)
>> +                     int append_only, int allow_empty,
>> +                     const unsigned char *prev, unsigned char *result)
>
> In other words, I have this suspicion that create_note() that
> removes is a wrong interface in the first place, and giving it
> a new allow_empty parameter to conditionally perform removal is
> making it worse.  No?

I agree, and it's fixed in the re-roll. It turned into a slightly larger rewrite than anticipated, but I'm fairly happy with the result.

...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 12 in “[PATCHv3 0/5] Handling empty notes”
  1. Johan HerlandNov 7, 2014
  2. 1/5 builtin/notes: Fix premature failure when trying to add the empty blobJohan Herland, Nov 7, 2014
  3. 2/5 t3301: Verify that 'git notes' removes empty notes by defaultJohan Herland, Nov 7, 2014
  4. Junio C HamanoNov 7, 2014
  5. 3/5 builtin/notes: Add --allow-empty, to allow storing empty notesJohan Herland, Nov 7, 2014
  6. Junio C HamanoNov 7, 2014
  7. Johan HerlandNov 9, 2014
  8. Junio C HamanoNov 10, 2014
  9. 4/5 notes: Empty notes should be shown by 'git log'Johan Herland, Nov 7, 2014
  10. Junio C HamanoNov 7, 2014
  11. 5/5 t3301: Use write_script(), nitpick whitespaceJohan Herland, Nov 7, 2014
  12. Junio C HamanoNov 7, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.