Skip to content

git notes

Johan Herland git 9 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v13 Latest30 patches 2 repliesIn review
  2. v1223 patches 7 repliesSuperseded
  3. v1120 patches 5 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v614 patches5 repliesSuperseded
v514 patches23 repliesSuperseded
v412 patches25 repliesSuperseded
v38 patches12 repliesSuperseded
v25 patches2 repliesSuperseded
v15 patches5 repliesSuperseded

Patches in v13 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/30Minor cosmetic fixes to notes.cnotes.c+4 -50 replies
2/30Notes API: get_commit_notes() -> format_note() + remove the commit restrictionnotes.c notes.h pretty.c+30 -220 replies
3/30Add tests for checking correct handling of $GIT_NOTES_REF and core.notesReft/t3301-notes.sh+48 -00 replies
4/30Notes API: init_notes(): Initialize the notes tree from the given notes refnotes.c notes.h+38 -120 replies
5/30Notes API: add_note(): Add note objects to the internal notes tree structurenotes.c notes.h+15 -00 replies
6/30Notes API: remove_note(): Remove note objects from the notes tree structurenotes.c notes.h+87 -10 replies
7/30Notes API: get_note(): Return the note annotating the given objectnotes.c notes.h+15 -70 replies
8/30Notes API: for_each_note(): Traverse the entire notes tree with a callbacknotes.c notes.h+180 -00 replies
9/30Notes API: write_notes_tree(): Store the notes tree in the databasenotes.c notes.h+180 -30 replies
10/30Notes API: Allow multiple concurrent notes trees with new struct notes_treenotes.c notes.h pretty.c+112 -660 replies
11/30Refactor notes concatenation into a flexible interface for combining notesnotes.c notes.h+112 -600 replies
12/30Builtin-ify git-notesDocumentation/git-notes.txt Makefile builtin-notes.c +4 more+350 -400 replies
13/30t3301: Verify successful annotation of non-commitst/t3301-notes.sh+17 -00 replies
14/30t3305: Verify that adding many notes with git-notes triggers increased fanoutt/t3305-notes-fanout.sh+50 -00 replies
15/30Teach notes code to properly preserve non-notes in the notes treenotes.c notes.h t/t3303-notes-subtrees.sh +1 more+233 -510 replies
16/30Teach builtin-notes to remove empty notesbuiltin-notes.c t/t3301-notes.sh+42 -40 replies
17/30builtin-notes: Add "remove" subcommand for removing existing notesDocumentation/git-notes.txt builtin-notes.c t/t3301-notes.sh+73 -340 replies
18/30t3305: Verify that removing notes triggers automatic fanout consolidationt/t3305-notes-fanout.sh+46 -10 replies
19/30Notes API: prune_notes(): Prune notes that belong to non-existing objectsnotes.c notes.h+51 -00 replies
20/30builtin-notes: Add "prune" subcommand for removing notes for missing objectsDocumentation/git-notes.txt builtin-notes.c t/t3306-notes-prune.sh+115 -110 replies
21/30Documentation: Generalize git-notes docs to 'objects' instead of 'commits'Documentation/git-notes.txt+20 -150 replies
22/30builtin-notes: Add "list" subcommand for listing note objectsDocumentation/git-notes.txt builtin-notes.c t/t3301-notes.sh+76 -60 replies
23/30builtin-notes: Add --message/--file aliases for -m/-F optionsDocumentation/git-notes.txt builtin-notes.c+4 -20 replies
24/30builtin-notes: Add "add" subcommand for adding notes to objectsDocumentation/git-notes.txt builtin-notes.c t/t3301-notes.sh+74 -220 replies
25/30builtin-notes: Add "append" subcommand for appending to note objectsDocumentation/git-notes.txt builtin-notes.c t/t3301-notes.sh+67 -90 replies
26/30builtin-notes: Deprecate the -m/-F options for "git notes edit"Documentation/git-notes.txt builtin-notes.c t/t3304-notes-mixed.sh +2 more+14 -80 replies
27/30builtin-notes: Refactor handling of -F option to allow combining -m and -Fbuiltin-notes.c t/t3301-notes.sh+73 -440 replies
28/30builtin-notes: Add -c/-C options for reusing notesDocumentation/git-notes.txt builtin-notes.c t/t3301-notes.sh+179 -124 replies
29/30builtin-notes: Misc. refactoring of argc and exit value handlingbuiltin-notes.c+36 -250 replies
30/30builtin-notes: Add "copy" subcommand for copying notes between objectsDocumentation/git-notes.txt builtin-notes.c t/t3301-notes.sh+102 -80 replies

Reviews trailers per patch

1 of 30 patches has a Reviewed-by or Acked-by.

PatchJunio C HamanoStephen Boyd
1/30
2/30
3/30
4/30
5/30
6/30
7/30
8/30
9/30
10/30
11/30
12/30
13/30
14/30
15/30
16/30
17/30
18/30
19/30
20/30
21/30
22/30
23/30
24/30Improved-by
25/30
26/30
27/30
28/30A-b
29/30
30/30

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v13 thread

Cover letter [PATCHv13 00/30] git notes

Hi,

Here is the 13th iteration of the git-notes series. Changes in this iteration are as follows:

- Patch #1 has improved its commit message

- Patch #7 (the get_note() API function) improved its header file docs.

- Patch #12 (Builtin-ify git-notes) received code to add some details of the current object (the object whose notes are currently being edited)to the template text displayed in the editor. Similar details were originally present in git-notes.sh, but was lost in the initial builtin-ification.

- Patch #22 (the 'list' subcommand) has learned to fail (instead of segfault) when asked to list notes for an object that has none.

- Patch #23 has been inserted to provide --message/--file aliases to the -m/-F options. This improves consistency with other git commands.

- Patch #24 (was #23) has been redone to provide the "git notes add" semantics suggested by Junio in the discussion following the previous iteration.

- Patch #25 introduces the "git notes append" subcommand which takes on the semantics of "git notes add" from the previous iteration.

- Patch #26 deprecates the -m/-F options for "git notes edit", since their semantics now overlap with "git notes add -f", and the behaviour is more intuitively captured and better documented with "git notes add -f"

- Patch #27 refactors some code in builtin-notes, to allow mixing -m and -F options again. This was originally allowed in git-notes.sh, but was disabled by the builin-ification. The refactoring also helps with clear the way for the next patch...

- Patch #28 introduces the -c/-C options to "git notes add/append". This allows re-use of existing notes object when making new note. The option names and semantics were inspired by "git commit".

- Patch #29 refactors the argc and exit value handling of builtin-notes, in preparation for the next patch

- Patch #30 introduces the "git notes copy" subcommand for copying notes from one object to another. This will come in handy when we want to bring notes across a commit rewrite (such as rebase/cherry-pick/amend).

There are ongoing discussions on how to further develop and integrate the notes feature. I try to summarize ideas below, although I don't plan to put any more stuff into _this_ patch series:

- Better integration with rebase/amend/cherry-pick. Optionally bring notes across a commit rewrite. Controlled by command-line options and/or config variables. Junio says:
I used to fix minor issues (styles, decl-after-stmt, etc.) using rebase-i long after running "am" in bulk, but these days I find myself going back to my "inbox" and fix them in MUA; this is only because I know these notes do not propagate across rebases and amends -- adjusting the workflow to the tool's limitation is not very good.

- Using multiple notes refs simultaneously. Junio says:
The interface to tell tools to use which notes ref to use should be able to say "these refs", not just "this ref" i.e. GIT_NOTES_REF=a:b just like PATH=a:b:c...); I am fairly certain that we would want to store different kind of information in separate notes trees and aggregate them, as we gain experience with notes.
When showing notes from multiple refs, we should also show from _which_ note ref a given note originates.
Of course, when _writing_ notes, only one ref should receive the created notes.

- Adding command-line options for specifying notes refs. Junio says:
There should be an interface to tell tools to use which notes refs via command line options; "!alias" does not TAB-complete, and "git lgm" above doesn't, either. "git log --notes=notes/amlog --notes=notes/other" would probably be the way to go.
Jakub suggests adding a --notes-ref="a:b:..." option, either to the git wrapper, or to all git subcommands that can do stuff with notes. Junio adds that the --notes-refs option should DWIM the given ref name (i.e. "foo" -> "refs/notes/foo").

- Add a "git notes grep" subcommand: Junio says:
While reviewing the "inbox", I sometimes wonder if I applied a message to somewhere already, but there is no obvious way to grep in the notes tree and get the object name that a note is attached to. Of course I know I can "git grep -c [email protected] notes/amlog" and it will give me something like:

notes/amlog:65807ee697a28cb30b8ad38ebb8b84cebd3f255d:1 notes/amlog:c789176020d6a008821e01af8b65f28abc138d4b:1

but this won't scale and needs scripting to mechanize, once we start rebalancing the notes tree with different fan-outs. The end user (me in this case) is interested in "set of objects that match this grep criteria", not "the pathnames the notes tree's implementation happens to use to store notes for them in the hierarchy".

- Add support for "^{notes}" (or "^@{}") to the rev-parse machinery, so that notes can be returned from e.g. "git cat-file --batch". This is somewhat complicated when combined with using multiple notes ref simultaneously (see above), but can be solved by using (Jakub's suggestions:) "^{notes:<namespace>}" (or "^@{<namespace>}").

- Merging notes trees. Junio suspects that we need a specialized merge strategy for notes trees. One example of such a strategy is to auto-concatenate conflicting notes, instead of forcing the user to edit away conflict markers. Note that such a solution should be fairly easy to implement on top of the current notes API, by loading both notes trees into the same struct notes_tree, while using combine_notes == combine_notes_concatenate().

- Matthieu Moy and Sverre Rabbelier suggests to add notes support to
format-patch: Notes stored in e.g. the "refs/notes/format-patch" ref are added to the "comments section" (i.e. following the '---' separator) of generated patches. There is also some discussion on whether notes should be added as custom headers to the email generated by format-patch.

- Special handling of notes on fetch? Tags are autofollowed; does it make sense to do something similar for notes? Guiseppe notes:
Tags have the idiosincracy of living in the same namespace regardless of where they come from, and I believe there a little too high a risk of conflicts to do this with notes too. It might make sense to add a default fetch of +refs/notes/*:refs/notes/remotes/<remote>/*, but the real question is what would pushing do, in case of conflicting notes.

- Note objects that are trees (instead of blobs). Peff originally proposed the idea of storing multiple notes for one object in a single notes ref by having the note object itself be a tree which contained note blobs (with well-defined names). Jon Seymour wanted to expand this idea to allow _arbitrary_ tree structures to be stored as notes. However, this will cause problems when trying to interpret notes in a consistent manner (i.e. how would "git log" display a tree of notes attached to a single commit). Problems may also arise when optimizing the notes tree structure itself. Peff instead suggests to add another level of indirection, and store the tree _SHA1_ in the note (instead of the tree object itself), and then teach a few tools (git-fsck, git-metadata?) to dereference the SHA1 when needed.

(- Rewrite fast-import notes code to use new notes API with support for
non-notes.)

Have fun! :)

...Johan

Johan Herland (30):
Minor cosmetic fixes to notes.c
Notes API: get_commit_notes() -> format_note() + remove the commit restriction Add tests for checking correct handling of $GIT_NOTES_REF and core.notesRef Notes API: init_notes(): Initialize the notes tree from the given notes ref Notes API: add_note(): Add note objects to the internal notes tree structure Notes API: remove_note(): Remove note objects from the notes tree structure Notes API: get_note(): Return the note annotating the given object Notes API: for_each_note(): Traverse the entire notes tree with a callback Notes API: write_notes_tree(): Store the notes tree in the database Notes API: Allow multiple concurrent notes trees with new struct notes_tree Refactor notes concatenation into a flexible interface for combining notes Builtin-ify git-notes
t3301: Verify successful annotation of non-commits
t3305: Verify that adding many notes with git-notes triggers increased fanout Teach notes code to properly preserve non-notes in the notes tree Teach builtin-notes to remove empty notes
builtin-notes: Add "remove" subcommand for removing existing notes
t3305: Verify that removing notes triggers automatic fanout consolidation Notes API: prune_notes(): Prune notes that belong to non-existing objects
builtin-notes: Add "prune" subcommand for removing notes for missing objects
Documentation: Generalize git-notes docs to 'objects' instead of 'commits'
builtin-notes: Add "list" subcommand for listing note objects
builtin-notes: Add --message/--file aliases for -m/-F options
builtin-notes: Add "add" subcommand for adding notes to objects
builtin-notes: Add "append" subcommand for appending to note objects
builtin-notes: Deprecate the -m/-F options for "git notes edit"
builtin-notes: Refactor handling of -F option to allow combining -m and -F
builtin-notes: Add -c/-C options for reusing notes
builtin-notes: Misc. refactoring of argc and exit value handling
builtin-notes: Add "copy" subcommand for copying notes between objects

 Documentation/git-notes.txt                   |   91 +++-
 Makefile                                      |    2 +-
 builtin-notes.c                               |  459 ++++++++++++++
 builtin.h                                     |    3 +
 git-notes.sh => contrib/examples/git-notes.sh |    0
 git.c                                         |    1 +
 notes.c                                       |  843 +++++++++++++++++++++----
 notes.h                                       |  196 ++++++-
 pretty.c                                      |    9 +-
 t/t3301-notes.sh                              |  510 ++++++++++++++-
 t/t3303-notes-subtrees.sh                     |   28 +-
 t/t3304-notes-mixed.sh                        |   36 +-
 t/t3305-notes-fanout.sh                       |   95 +++
 t/t3306-notes-prune.sh                        |   94 +++
 14 files changed, 2171 insertions(+), 196 deletions(-)
 create mode 100644 builtin-notes.c
 rename git-notes.sh => contrib/examples/git-notes.sh (100%)
 create mode 100755 t/t3305-notes-fanout.sh
 create mode 100755 t/t3306-notes-prune.sh