smart-http: Don't use Expect: 100-Continue
[git.git] / t / t3301-notes.sh
blob714626d2d61ea95465b838595fe9b5e32b8f55b1
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test commit notes'
8 . ./test-lib.sh
10 cat > fake_editor.sh << \EOF
11 #!/bin/sh
12 echo "$MSG" > "$1"
13 echo "$MSG" >& 2
14 EOF
15 chmod a+x fake_editor.sh
16 VISUAL=./fake_editor.sh
17 export VISUAL
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 '
24 : > a1 &&
25 git add a1 &&
26 test_tick &&
27 git commit -m 1st &&
28 : > a2 &&
29 git add a2 &&
30 test_tick &&
31 git commit -m 2nd
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) &&
64 git show HEAD^ &&
65 test_must_fail git notes show HEAD^
68 cat > expect << EOF
69 commit 268048bfb8a1fb38e703baceb8ab235421bf80c5
70 Author: A U Thor <author@example.com>
71 Date: Thu Apr 7 15:14:13 2005 -0700
73 2nd
75 Notes:
77 EOF
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)' '
85 : > a3 &&
86 git add a3 &&
87 test_tick &&
88 git commit -m 3rd &&
89 MSG="b3
90 c3c3c3c3
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
99 3rd
101 Notes:
103 c3c3c3c3
104 d3d3d3
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)' '
115 : > a4 &&
116 git add a4 &&
117 test_tick &&
118 git commit -m 4th &&
119 echo "xyzzy" > note5 &&
120 git notes edit -m spam -F note5 -m "foo
122 baz"
125 whitespace=" "
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
133 Notes:
134 spam
135 $whitespace
136 xyzzy
137 $whitespace
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
151 cat >expect << EOF
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
165 cat >>expect <<EOF
167 Notes:
168 spam
169 $whitespace
170 xyzzy
171 $whitespace
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 &&
183 ! grep spam output
186 test_expect_success 'git format-patch does not show notes' '
187 git format-patch -1 --stdout >output &&
188 ! grep spam output
191 test_expect_success 'git format-patch --show-notes does show notes' '
192 git format-patch --show-notes -1 --stdout >output &&
193 grep spam output
196 for pretty in \
197 "" --pretty --pretty=raw --pretty=short --pretty=medium \
198 --pretty=full --pretty=fuller --pretty=format:%s --oneline
200 case "$pretty" in
201 "") p= not= negate="" ;;
202 ?*) p="$pretty" not=" not" negate="!" ;;
203 esac
204 test_expect_success "git show $pretty does$not show notes" '
205 git show $p >output &&
206 eval "$negate grep spam output"
208 done
210 test_done