Skip to content

Commit 5a96715

Browse files
committed
Merge branch 'tb/diff-tree-with-notes'
"git diff-tree --pretty --notes" used to hit an assertion failure, as it forgot to initialize the notes subsystem. * tb/diff-tree-with-notes: diff-tree.c: load notes machinery when required
2 parents e08387d + 5778b22 commit 5a96715

7 files changed

+78
-0
lines changed

builtin/diff-tree.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
109109
struct object *tree1, *tree2;
110110
static struct rev_info *opt = &log_tree_opt;
111111
struct setup_revision_opt s_r_opt;
112+
struct userformat_want w;
112113
int read_stdin = 0;
113114

114115
if (argc == 2 && !strcmp(argv[1], "-h"))
@@ -127,6 +128,14 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
127128
precompose_argv(argc, argv);
128129
argc = setup_revisions(argc, argv, opt, &s_r_opt);
129130

131+
memset(&w, 0, sizeof(w));
132+
userformat_find_requirements(NULL, &w);
133+
134+
if (!opt->show_notes_given && w.notes)
135+
opt->show_notes = 1;
136+
if (opt->show_notes)
137+
load_display_notes(&opt->notes_opt);
138+
130139
while (--argc > 0) {
131140
const char *arg = *++argv;
132141

t/t4013-diff-various.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ test_expect_success setup '
9595
git commit -m "update mode" &&
9696
git checkout -f master &&
9797
98+
GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
99+
GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
100+
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
101+
git checkout -b note initial &&
102+
git update-index --chmod=+x file2 &&
103+
git commit -m "update mode (file2)" &&
104+
git notes add -m "note" &&
105+
git checkout -f master &&
106+
98107
# Same merge as master, but with parents reversed. Hide it in a
99108
# pseudo-ref to avoid impacting tests with --all.
100109
commit=$(echo reverse |
@@ -398,6 +407,9 @@ diff --no-index --raw --no-abbrev dir2 dir
398407
399408
diff-tree --pretty --root --stat --compact-summary initial
400409
diff-tree --pretty -R --root --stat --compact-summary initial
410+
diff-tree --pretty note
411+
diff-tree --pretty --notes note
412+
diff-tree --format=%N note
401413
diff-tree --stat --compact-summary initial mode
402414
diff-tree -R --stat --compact-summary initial mode
403415
EOF
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$ git diff-tree --format=%N note
2+
note
3+
4+
5+
:100644 100755 01e79c32a8c99c557f0757da7cb6d65b3414466d 01e79c32a8c99c557f0757da7cb6d65b3414466d M file2
6+
$
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
$ git diff-tree --pretty --notes note
2+
commit a6f364368ca320bc5a92e18912e16fa6b3dff598
3+
Author: A U Thor <[email protected]>
4+
Date: Mon Jun 26 00:06:00 2006 +0000
5+
6+
update mode (file2)
7+
8+
Notes:
9+
note
10+
11+
:100644 100755 01e79c32a8c99c557f0757da7cb6d65b3414466d 01e79c32a8c99c557f0757da7cb6d65b3414466d M file2
12+
$

t/t4013/diff.diff-tree_--pretty_note

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$ git diff-tree --pretty note
2+
commit a6f364368ca320bc5a92e18912e16fa6b3dff598
3+
Author: A U Thor <[email protected]>
4+
Date: Mon Jun 26 00:06:00 2006 +0000
5+
6+
update mode (file2)
7+
8+
:100644 100755 01e79c32a8c99c557f0757da7cb6d65b3414466d 01e79c32a8c99c557f0757da7cb6d65b3414466d M file2
9+
$

t/t4013/diff.log_--decorate=full_--all

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,27 @@ Date: Mon Jun 26 00:06:00 2006 +0000
55

66
update mode
77

8+
commit a6f364368ca320bc5a92e18912e16fa6b3dff598 (refs/heads/note)
9+
Author: A U Thor <[email protected]>
10+
Date: Mon Jun 26 00:06:00 2006 +0000
11+
12+
update mode (file2)
13+
14+
Notes:
15+
note
16+
817
commit cd4e72fd96faed3f0ba949dc42967430374e2290 (refs/heads/rearrange)
918
Author: A U Thor <[email protected]>
1019
Date: Mon Jun 26 00:06:00 2006 +0000
1120

1221
Rearranged lines in dir/sub
1322

23+
commit cbacedd14cb8b89255a2c02b59e77a2e9a8021a0 (refs/notes/commits)
24+
Author: A U Thor <[email protected]>
25+
Date: Mon Jun 26 00:06:00 2006 +0000
26+
27+
Notes added by 'git notes add'
28+
1429
commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD -> refs/heads/master)
1530
Merge: 9a6d494 c7a2ab9
1631
Author: A U Thor <[email protected]>

t/t4013/diff.log_--decorate_--all

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,27 @@ Date: Mon Jun 26 00:06:00 2006 +0000
55

66
update mode
77

8+
commit a6f364368ca320bc5a92e18912e16fa6b3dff598 (note)
9+
Author: A U Thor <[email protected]>
10+
Date: Mon Jun 26 00:06:00 2006 +0000
11+
12+
update mode (file2)
13+
14+
Notes:
15+
note
16+
817
commit cd4e72fd96faed3f0ba949dc42967430374e2290 (rearrange)
918
Author: A U Thor <[email protected]>
1019
Date: Mon Jun 26 00:06:00 2006 +0000
1120

1221
Rearranged lines in dir/sub
1322

23+
commit cbacedd14cb8b89255a2c02b59e77a2e9a8021a0 (refs/notes/commits)
24+
Author: A U Thor <[email protected]>
25+
Date: Mon Jun 26 00:06:00 2006 +0000
26+
27+
Notes added by 'git notes add'
28+
1429
commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD -> master)
1530
Merge: 9a6d494 c7a2ab9
1631
Author: A U Thor <[email protected]>

0 commit comments

Comments
 (0)