3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='Test commit notes'
10 cat > fake_editor.sh
<< \EOF
14 chmod a
+x fake_editor.sh
15 VISUAL
=.
/fake_editor.sh
18 test_expect_success
'cannot annotate non-existing HEAD' '
19 (MSG=3 && export MSG && test_must_fail git notes edit)
22 test_expect_success setup
'
33 test_expect_success
'need valid notes ref' '
34 (MSG=1 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
35 test_must_fail git notes edit) &&
36 (MSG=2 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
37 test_must_fail git notes show)
40 test_expect_success
'refusing to edit in refs/heads/' '
41 (MSG=1 GIT_NOTES_REF=refs/heads/bogus &&
42 export MSG GIT_NOTES_REF &&
43 test_must_fail git notes edit)
46 test_expect_success
'refusing to edit in refs/remotes/' '
47 (MSG=1 GIT_NOTES_REF=refs/remotes/bogus &&
48 export MSG GIT_NOTES_REF &&
49 test_must_fail git notes edit)
52 # 1 indicates caught gracefully by die, 128 means git-show barked
53 test_expect_success
'handle empty notes gracefully' '
54 git notes show ; test 1 = $?
57 test_expect_success
'create notes' '
58 git config core.notesRef refs/notes/commits &&
59 MSG=b1 git notes edit &&
60 test ! -f .git/new-notes &&
61 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
62 test b1 = $(git notes show) &&
64 test_must_fail git notes show HEAD^
68 commit 268048bfb8a1fb38e703baceb8ab235421bf80c5
69 Author: A U Thor <author@example.com>
70 Date: Thu Apr 7 15:14:13 2005 -0700
78 test_expect_success
'show notes' '
79 ! (git cat-file commit HEAD | grep b1) &&
80 git log -1 > output &&
81 test_cmp expect output
83 test_expect_success
'create multi-line notes (setup)' '
90 d3d3d3" git notes edit
93 cat > expect-multiline
<< EOF
94 commit 1584215f1d29c65e99c6c6848626553fdd07fd75
95 Author: A U Thor <author@example.com>
96 Date: Thu Apr 7 15:15:13 2005 -0700
106 printf "\n" >> expect-multiline
107 cat expect
>> expect-multiline
109 test_expect_success
'show multi-line notes' '
110 git log -2 > output &&
111 test_cmp expect-multiline output
113 test_expect_success
'create -m and -F notes (setup)' '
118 echo "xyzzy" > note5 &&
119 git notes edit -m spam -F note5 -m "foo
125 cat > expect-m-and-F
<< EOF
126 commit 15023535574ded8b1a89052b32673f84cf9582b8
127 Author: A U Thor <author@example.com>
128 Date: Thu Apr 7 15:16:13 2005 -0700
142 printf "\n" >> expect-m-and-F
143 cat expect-multiline
>> expect-m-and-F
145 test_expect_success
'show -m and -F notes' '
146 git log -3 > output &&
147 test_cmp expect-m-and-F output
151 commit 15023535574ded8b1a89052b32673f84cf9582b8
152 tree e070e3af51011e47b183c33adf9736736a525709
153 parent 1584215f1d29c65e99c6c6848626553fdd07fd75
154 author A U Thor <author@example.com> 1112912173 -0700
155 committer C O Mitter <committer@example.com> 1112912173 -0700
159 test_expect_success
'git log --pretty=raw does not show notes' '
160 git log -1 --pretty=raw >output &&
161 test_cmp expect output
175 test_expect_success
'git log --show-notes' '
176 git log -1 --pretty=raw --show-notes >output &&
177 test_cmp expect output
180 test_expect_success
'git log --no-notes' '
181 git log -1 --no-notes >output &&
185 test_expect_success
'git format-patch does not show notes' '
186 git format-patch -1 --stdout >output &&
190 test_expect_success
'git format-patch --show-notes does show notes' '
191 git format-patch --show-notes -1 --stdout >output &&
196 "" --pretty --pretty=raw
--pretty=short
--pretty=medium \
197 --pretty=full
--pretty=fuller
--pretty=format
:%s
--oneline
200 "") p
= not
= negate
="" ;;
201 ?
*) p
="$pretty" not
=" not" negate
="!" ;;
203 test_expect_success
"git show $pretty does$not show notes" '
204 git show $p >output &&
205 eval "$negate grep spam output"