mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
diff-tree.c: load notes machinery when required
Since its introduction in 7249e91 (revision.c: support --notes
command-line option, 2011-03-29), 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,
and harden this behavior against regression with a test in t4013. (Note
that the added ref in this test requires updating two unrelated tests
which use 'log --all', and thus need to learn about the new refs).
Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
d0654dc308
commit
5778b22b3d
6
t/t4013/diff.diff-tree_--format=%N_note
Normal file
6
t/t4013/diff.diff-tree_--format=%N_note
Normal file
@@ -0,0 +1,6 @@
|
||||
$ git diff-tree --format=%N note
|
||||
note
|
||||
|
||||
|
||||
:100644 100755 01e79c32a8c99c557f0757da7cb6d65b3414466d 01e79c32a8c99c557f0757da7cb6d65b3414466d M file2
|
||||
$
|
||||
12
t/t4013/diff.diff-tree_--pretty_--notes_note
Normal file
12
t/t4013/diff.diff-tree_--pretty_--notes_note
Normal file
@@ -0,0 +1,12 @@
|
||||
$ git diff-tree --pretty --notes note
|
||||
commit a6f364368ca320bc5a92e18912e16fa6b3dff598
|
||||
Author: A U Thor <author@example.com>
|
||||
Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
update mode (file2)
|
||||
|
||||
Notes:
|
||||
note
|
||||
|
||||
:100644 100755 01e79c32a8c99c557f0757da7cb6d65b3414466d 01e79c32a8c99c557f0757da7cb6d65b3414466d M file2
|
||||
$
|
||||
9
t/t4013/diff.diff-tree_--pretty_note
Normal file
9
t/t4013/diff.diff-tree_--pretty_note
Normal file
@@ -0,0 +1,9 @@
|
||||
$ git diff-tree --pretty note
|
||||
commit a6f364368ca320bc5a92e18912e16fa6b3dff598
|
||||
Author: A U Thor <author@example.com>
|
||||
Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
update mode (file2)
|
||||
|
||||
:100644 100755 01e79c32a8c99c557f0757da7cb6d65b3414466d 01e79c32a8c99c557f0757da7cb6d65b3414466d M file2
|
||||
$
|
||||
@@ -5,12 +5,27 @@ Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
update mode
|
||||
|
||||
commit a6f364368ca320bc5a92e18912e16fa6b3dff598 (refs/heads/note)
|
||||
Author: A U Thor <author@example.com>
|
||||
Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
update mode (file2)
|
||||
|
||||
Notes:
|
||||
note
|
||||
|
||||
commit cd4e72fd96faed3f0ba949dc42967430374e2290 (refs/heads/rearrange)
|
||||
Author: A U Thor <author@example.com>
|
||||
Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
Rearranged lines in dir/sub
|
||||
|
||||
commit cbacedd14cb8b89255a2c02b59e77a2e9a8021a0 (refs/notes/commits)
|
||||
Author: A U Thor <author@example.com>
|
||||
Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
Notes added by 'git notes add'
|
||||
|
||||
commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD -> refs/heads/master)
|
||||
Merge: 9a6d494 c7a2ab9
|
||||
Author: A U Thor <author@example.com>
|
||||
|
||||
@@ -5,12 +5,27 @@ Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
update mode
|
||||
|
||||
commit a6f364368ca320bc5a92e18912e16fa6b3dff598 (note)
|
||||
Author: A U Thor <author@example.com>
|
||||
Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
update mode (file2)
|
||||
|
||||
Notes:
|
||||
note
|
||||
|
||||
commit cd4e72fd96faed3f0ba949dc42967430374e2290 (rearrange)
|
||||
Author: A U Thor <author@example.com>
|
||||
Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
Rearranged lines in dir/sub
|
||||
|
||||
commit cbacedd14cb8b89255a2c02b59e77a2e9a8021a0 (refs/notes/commits)
|
||||
Author: A U Thor <author@example.com>
|
||||
Date: Mon Jun 26 00:06:00 2006 +0000
|
||||
|
||||
Notes added by 'git notes add'
|
||||
|
||||
commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD -> master)
|
||||
Merge: 9a6d494 c7a2ab9
|
||||
Author: A U Thor <author@example.com>
|
||||
|
||||
Reference in New Issue
Block a user