git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug/request: the empty string should be a valid git note
@ 2014-09-20 19:47 James H. Fisher
  2014-09-20 21:50 ` James H. Fisher
  2014-09-21  1:44 ` Johan Herland
  0 siblings, 2 replies; 8+ messages in thread
From: James H. Fisher @ 2014-09-20 19:47 UTC (permalink / raw)
  To: git@vger.kernel.org

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-09-22 17:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-20 19:47 Bug/request: the empty string should be a valid git note James H. Fisher
2014-09-20 21:50 ` James H. Fisher
2014-09-21  1:44 ` Johan Herland
2014-09-21  3:00   ` [RFC/PATCH] notes: Allow adding empty notes with -C Johan Herland
2014-09-21  8:53     ` Torsten Bögershausen
2014-09-21  9:46       ` Johan Herland
2014-09-21 23:32   ` Bug/request: the empty string should be a valid git note Kyle J. McKay
2014-09-22 17:39     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).