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

Re: Bug/request: the empty string should be a valid git note

From
JFJames H. Fisher <jhf@trifork.com>
Date
Sep 20, 2014, 21:50 UTC
Message-ID
<9AE29EAE-8471-4F1F-B4CB-37FA830E3DAF@trifork.com>
In-Reply-To
<F9750CC0-3FAC-4B50-AB6A-BFD6A7D0BE97@trifork.com>
Apologies for re-sending; unclear whether my email was delivered since I sent it before my subscription was confirmed.
On 20 Sep 2014, at 20:47, James H. Fisher <jhf@trifork.com> wrote:
Show 38 quoted lines
> In the documentation for git notes [1] I read:
> 
>    In principle, a note is a regular Git blob, and any kind of (non-)format is accepted.
> 
> Then, since the empty string is a valid regular Git blob, the empty string is also a valid git note.
> 
> Therefore this behavior was unexpected for me:
> 
>> git notes --ref=foo add -m ''
>    Removing note for object 97b8860c071898d9e162678ea1035a8ced2f8b1f
> 
> I was surprised to see that this behavior was deliberately introduced:
> 
>> git log -1 a0b4dfa
>    commit a0b4dfa9b35a2ebac578ea5547b041bb78557238
>    Author: Johan Herland <johan@herland.net>
>    Date:   Sat Feb 13 22:28:24 2010 +0100
> 
>        Teach builtin-notes to remove empty notes
> 
>        When the result of editing a note is an empty string, the associated note
>        entry should be deleted from the notes tree.
> 
>        This allows deleting notes by invoking either "git notes -m ''" or
>        "git notes -F /dev/null".
> 
>        Signed-off-by: Johan Herland <johan@herland.net>
>        Signed-off-by: Junio C Hamano <gitster@pobox.com>
> 
> I don’t understand what the motivation for this change was. Yes, it "allows deleting notes" by providing the empty string, but there is a specific subcommand for removal of a note, `git notes remove`, which makes this intention much clearer.
> 
> I have specific motivation for wanting to store the empty string as a git note, as distinct from the non-existence of a note for the object. (Specifically I have a tool to annotate a commit with a list of files that satisfy a certain condition. The empty string represents the empty list, a valid value which asserts that no files satisfied the condition. I can imagine many other use cases for which the empty string is a useful git note.)
> 
> Does anyone know why we have the existing behavior? Is it for "technical reasons” or was it actually considered desirable?
> 
> James Fisher 
> 
> [1]: https://www.kernel.org/pub/software/scm/git/docs/git-notes.html
Previous: James H. FisherNext: Johan Herland
Message 2 of 8 in “Bug/request: the empty string should be a valid git note”
  1. James H. FisherSep 20, 2014
  2. James H. FisherSep 20, 2014
  3. Johan HerlandSep 21, 2014
  4. notes: Allow adding empty notes with -CJohan Herland, Sep 21, 2014
  5. Torsten BögershausenSep 21, 2014
  6. Johan HerlandSep 21, 2014
  7. Kyle J. McKaySep 21, 2014
  8. Junio C HamanoSep 22, 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.