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

Re: [PATCH 00/15] git-note: A mechanisim for providing free-form after-the-fact annotations on commits

From
Junio C Hamano <junkio@cox.net>
Date
May 27, 2007, 20:09 UTC
Message-ID
<7vejl2do5w.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200705271608.02122.johan@herland.net>
Johan Herland <johan@herland.net> writes:
> I've been working on combining tag objects and --decorate into a useful
> proof-of-concept that provides the after-the-fact commit annotations I
> requested above, and here's the result:
> ...

Very nicely presented. I appreciate [PATCH 0/N] summary for a series like this that talks about not just what and how it does, but focus more on why it does it in a particular way, on design issues, and decisions. It makes it very pleasant to comment on the series to have a well written summary like this, because in the early stage of a review cycle, we would want to talk about the design, ignoring implementation details.

Show 5 quoted lines
> However, there are still some remaining questions:
>
> - Is the creation of a unique tag name (i.e. the 'tag' field _inside_ the
>   object) for note objects really necessary? Which parts of the system rely
>   on these names to be unique across tag objects?

None. Although your use of note-X{40} would make "recovering" easier, I would imagine.

> - Should notes have their own object type instead of piggy-backing on "tag"?
>
> - What about having a note object type with minimal header fields, and make
>   tags just a special case of a note object with an extra tag name header?
Two things struck me:
 - The "reverse" mapping 'note' tag uses uses FS as a database.
   Clever but would not scale well.
 - *BUT* the reverse mapping 'note' tag uses is exactly what we
    would want to use for tags that are not notes, for tools
    like gitk to attach little flags to commits.

So maybe we _should_ not even need to call this a new 'notes' system. I am just saying your second point above in a different way, but I suspect all what is needed is to make the filtering and presentation of tag objects a bit more flexible, and making use of the 'peeled' (see .git/packed-refs, for example) mapping ultra cheap for ordinary tags.

What you would need are:
 - Ultra-cheap reverse lookup: "I have an object; which tags
   point at this?"
   You solved it with refs/notes/<sha1-of-tagged>/, but it would
   be useful to extend this to any tag in general.
 - Easy way to filter the above question: "I have an object;
   which tags of this particlar class point at this?"
   You are essentially prefiltering by only making notes tags
   available via refs/notes/ hierarchy, but you can also filter
   with your naming convention "tag notes-<sha1>".  We _could_
   (I am not seriously suggesting this yet as I haven't thought
   through the issues yet) allow "keyword" header to tag
   objects, and allow --decorate='kwd1,kwd2,...' to limit the
   tags we take object decorations from the ones that has one of
   the specified keywords.  If we do that, I suspect your
   'notes' system would naturally fall out as regular tags that
   happen to have a keyword header with 'note' on it.
> - What about notes on notes? How are tags on tags treated? How should they be
>   treated?

You can create a tag object that points at another tag. When we peel a tag using "^{}" notation, currently it is peeled all the way until we hit a non tag, so if you need to look at intermediate tags, you need to parse them yourself. IOW, there is no Porcelain feature to let you take advantage of this capability, easily. But we could use this to say "I attest that he tagged that object".

> - Currently noted objects (notees?) are treated as reachable from their
>   associated notes, i.e. like tags. This means that an otherwise dangling
>   object will not be detected and removed if it has associated notes.

I think it largely depends on how you intend to use 'notes' if this is a problem.

The reachability issue is not limited to cruft removal; it also affects the fetching.

I would imagine the intended use of a 'note' is to annotate objects (mostly commits, but not necessarily) after the fact, e.g. "this is reported to fix the issue 35833". You may or may not want to propagate this across repositories, and the way you implemented it is to have a ref pointing at the note -- then it would make it fetchable by other people. Otherwise it would not. With your implementation, unfortunately, not having a ref under refs/notes/ would also make the information unavailable to yourself.

I think the semantics you would want, when a 'note' object that points at another object (pointee) exists, is to allow creating a fake (reverse) reachability that says "pointee points at the note". When such a reachability exists:

 - A fetch from such a repository that transfers out the pointee
   will drag the note attached to it along with it (so you would
   teach rev-list/upload-pack about the extended reachability).
 - Incidentally, having a ref that points at the pointee is
   enough to protect the note that points at the pointee from
   getting pruned (so you would teach fsck/prune about the
   extended reachability).

Othewise, the 'note' is subject to garbage collection. This is pretty much an extension to the existing 'grafts' mechanism, which can only override commit and its parents; what is done in the above is to add (not override) to existing reachability to any object (not just commit, but anything that can get 'noted').

Previous: Johan HerlandNext: Johan Herland
Message 26 of 53 in “[RFC] Second parent for reverts”
  1. Daniel BarkalowMay 9, 2007
  2. Johannes SchindelinMay 9, 2007
  3. Shawn O. PearceMay 9, 2007
  4. Johan HerlandMay 9, 2007
  5. Junio C HamanoMay 9, 2007
  6. Linus TorvaldsMay 9, 2007
  7. Linus TorvaldsMay 10, 2007
  8. Johan HerlandMay 10, 2007
  9. Linus TorvaldsMay 10, 2007
  10. 00/15 git-note: A mechanisim for providing free-form after-the-fact annotations on commitsJohan Herland, May 27, 2007
  11. 01/15 git-note: Add git-note command for adding/listing/deleting git notesJohan Herland, May 27, 2007
  12. 02/15 git-note: (Documentation) Add git-note manual pageJohan Herland, May 27, 2007
  13. 03/15 git-note: (Administrivia) Add git-note to Makefile, .gitignore, etc.Johan Herland, May 27, 2007
  14. 04/15 git-note: (Plumbing) Add plumbing-level support for git notesJohan Herland, May 27, 2007
  15. 05/15 git-note: (Plumbing) Add support for git notes to git-rev-parse and git-show-refJohan Herland, May 27, 2007
  16. 06/15 git-note: (Documentation) Explain the new '--notes' option to git-rev-parse and git-show-refJohan Herland, May 27, 2007
  17. 07/15 git-note: (Almost plumbing) Add support for git notes to git-pack-refs and git-fsckJohan Herland, May 27, 2007
  18. 08/15 git-note: (Decorations) Add note decorations to "git-{log,show,whatchanged} --decorate"Johan Herland, May 27, 2007
  19. 09/15 git-note: (Documentation) Explain new behaviour of --decorate in git-{log,show,whatchanged}Johan Herland, May 27, 2007
  20. 10/15 git-note: (Transfer) Teach git-clone how to clone notesJohan Herland, May 27, 2007
  21. 11/15 git-note: (Transfer) Teach git-fetch to auto-follow notesJohan Herland, May 27, 2007
  22. 12/15 git-note: (Transfer) Teach git-push to push notes when --all or --notes is givenJohan Herland, May 27, 2007
  23. 13/15 git-note: (Documentation) Explain the new --notes option to git-pushJohan Herland, May 27, 2007
  24. 14/15 git-note: (Tests) Add tests for git-note and associated functionalityJohan Herland, May 27, 2007
  25. 15/15 git-note: Add display of notes to gitkJohan Herland, May 27, 2007
  26. Junio C HamanoMay 27, 2007
  27. Johan HerlandMay 28, 2007
  28. Jakub NarebskiMay 28, 2007
  29. Linus TorvaldsMay 28, 2007
  30. Johan HerlandMay 28, 2007
  31. Linus TorvaldsMay 28, 2007
  32. Johan HerlandMay 28, 2007
  33. Linus TorvaldsMay 28, 2007
  34. Johan HerlandMay 28, 2007
  35. Junio C HamanoMay 28, 2007
  36. Shawn O. PearceMay 28, 2007
  37. Johannes SchindelinMay 28, 2007
  38. Linus TorvaldsMay 29, 2007
  39. Shawn O. PearceMay 29, 2007
  40. Jakub NarebskiMay 29, 2007
  41. Andy ParkinsMay 29, 2007
  42. Johannes SchindelinMay 29, 2007
  43. Johan HerlandMay 29, 2007
  44. Jeff KingMay 29, 2007
  45. Johan HerlandMay 29, 2007
  46. Junio C HamanoMay 28, 2007
  47. Shawn O. PearceMay 28, 2007
  48. Add fsck_verify_ref_to_tag_object() to verify that refname matches name stored in tag objectJohan Herland, May 28, 2007
  49. Michael S. TsirkinMay 28, 2007
  50. Michael S. TsirkinMay 28, 2007
  51. Johan HerlandMay 28, 2007
  52. Martin LanghoffMay 10, 2007
  53. Junio C HamanoMay 10, 2007

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.