3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test commit notes'
10 cat > fake_editor.sh << \EOF
15 chmod a+x fake_editor.sh
16 VISUAL=./fake_editor.sh
19 test_expect_success 'cannot annotate non-existing HEAD' '
20 (MSG=3 && export MSG && test_must_fail git notes edit)
23 test_expect_success setup '
34 test_expect_success 'need valid notes ref' '
35 (MSG=1 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
36 test_must_fail git notes edit) &&
37 (MSG=2 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
38 test_must_fail git notes show)
41 test_expect_success 'refusing to edit in refs/heads/' '
42 (MSG=1 GIT_NOTES_REF=refs/heads/bogus &&
43 export MSG GIT_NOTES_REF &&
44 test_must_fail git notes edit)
47 test_expect_success 'refusing to edit in refs/remotes/' '
48 (MSG=1 GIT_NOTES_REF=refs/remotes/bogus &&
49 export MSG GIT_NOTES_REF &&
50 test_must_fail git notes edit)
53 # 1 indicates caught gracefully by die, 128 means git-show barked
54 test_expect_success 'handle empty notes gracefully' '
55 git notes show ; test 1 = $?
58 test_expect_success 'create notes' '
59 git config core.notesRef refs/notes/commits &&
60 MSG=b1 git notes edit &&
61 test ! -f .git/new-notes &&
62 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
63 test b1 = $(git notes show) &&
65 test_must_fail git notes show HEAD^
69 commit 268048bfb8a1fb38e703baceb8ab235421bf80c5
70 Author: A U Thor <author@example.com>
71 Date: Thu Apr 7 15:14:13 2005 -0700
79 test_expect_success 'show notes' '
80 ! (git cat-file commit HEAD | grep b1) &&
81 git log -1 > output &&
82 test_cmp expect output
84 test_expect_success 'create multi-line notes (setup)' '
91 d3d3d3" git notes edit
94 cat > expect-multiline << EOF
95 commit 1584215f1d29c65e99c6c6848626553fdd07fd75
96 Author: A U Thor <author@example.com>
97 Date: Thu Apr 7 15:15:13 2005 -0700
107 printf "\n" >> expect-multiline
108 cat expect >> expect-multiline
110 test_expect_success 'show multi-line notes' '
111 git log -2 > output &&
112 test_cmp expect-multiline output
114 test_expect_success 'create -m and -F notes (setup)' '
119 echo "xyzzy" > note5 &&
120 git notes edit -m spam -F note5 -m "foo
126 cat > expect-m-and-F << EOF
127 commit 15023535574ded8b1a89052b32673f84cf9582b8
128 Author: A U Thor <author@example.com>
129 Date: Thu Apr 7 15:16:13 2005 -0700
143 printf "\n" >> expect-m-and-F
144 cat expect-multiline >> expect-m-and-F
146 test_expect_success 'show -m and -F notes' '
147 git log -3 > output &&
148 test_cmp expect-m-and-F output
152 commit 15023535574ded8b1a89052b32673f84cf9582b8
153 tree e070e3af51011e47b183c33adf9736736a525709
154 parent 1584215f1d29c65e99c6c6848626553fdd07fd75
155 author A U Thor <author@example.com> 1112912173 -0700
156 committer C O Mitter <committer@example.com> 1112912173 -0700
160 test_expect_success 'git log --pretty=raw does not show notes' '
161 git log -1 --pretty=raw >output &&
162 test_cmp expect output
176 test_expect_success 'git log --show-notes' '
177 git log -1 --pretty=raw --show-notes >output &&
178 test_cmp expect output
181 test_expect_success 'git log --no-notes' '
182 git log -1 --no-notes >output &&
186 test_expect_success 'git format-patch does not show notes' '
187 git format-patch -1 --stdout >output &&
191 test_expect_success 'git format-patch --show-notes does show notes' '
192 git format-patch --show-notes -1 --stdout >output &&
197 "" --pretty --pretty=raw --pretty=short --pretty=medium \
198 --pretty=full --pretty=fuller --pretty=format:%s --oneline
201 "") p= not= negate="" ;;
202 ?*) p="$pretty" not=" not" negate="!" ;;
204 test_expect_success "git show $pretty does$not show notes" '
205 git show $p >output &&
206 eval "$negate grep spam output"