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
@ -109,6 +109,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
|
||||
struct object *tree1, *tree2;
|
||||
static struct rev_info *opt = &log_tree_opt;
|
||||
struct setup_revision_opt s_r_opt;
|
||||
struct userformat_want w;
|
||||
int read_stdin = 0;
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "-h"))
|
||||
@ -127,6 +128,14 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
|
||||
precompose_argv(argc, argv);
|
||||
argc = setup_revisions(argc, argv, opt, &s_r_opt);
|
||||
|
||||
memset(&w, 0, sizeof(w));
|
||||
userformat_find_requirements(NULL, &w);
|
||||
|
||||
if (!opt->show_notes_given && w.notes)
|
||||
opt->show_notes = 1;
|
||||
if (opt->show_notes)
|
||||
load_display_notes(&opt->notes_opt);
|
||||
|
||||
while (--argc > 0) {
|
||||
const char *arg = *++argv;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user