Another way:
git rev-list HEAD | git diff-tree --stdin
But, before Git 2.27 (Q2 2020), "git diff-tree --pretty --notes
" used to hit an assertion failure, as it forgot to initialize the notes subsystem.
See commit 5778b22 (21 Apr 2020) by Taylor Blau (ttaylorr
).
(Merged by Junio C Hamano -- gitster
-- in commit 5a96715, 28 Apr 2020)
diff-tree.c
: load notes machinery when required
Reported-by: Jeff King
Signed-off-by: Taylor Blau
Acked-by: Jeff King
Since its introduction in 7249e91 ("[
revision.c](https
://github.com/git/git/blob/5778b22b3d690495e724276663c36ccd5329da4d/revision.c): support --notes command-line option", 2011-03-29, Git v1.7.6-rc0 -- merge listed in batch #0), combining '--notes
' with any option that causes us to format notes (e.g., '--pretty
', '--format="%N"
', etc) results in a failed assertion at runtime.
$ git rev-list HEAD | git diff-tree --stdin --pretty=medium --notes
commit 8f3d9f354286745c751374f5f1fcafee6b3f3136
git: notes.c:1308: format_display_notes: Assertion `display_notes_trees' failed.
Aborted
This failure is due to diff-tree not calling 'load_display_notes
' to initialize the notes machinery.
Ordinarily, this failure isn't triggered, because it requires passing both '--notes
' and another of the above mentioned options.
In the case of '--pretty
', for example, we set 'opt->verbose_header
', causing 'show_log()
' to eventually call 'format_display_notes()
', which expects a non-NULL 'display_note_trees
'.
Without initializing the notes machinery, 'display_note_trees
' remains NULL
, and thus triggers an assertion failure.
Fix this by initializing the notes machinery after parsing our options.