doc/bundle: Use the more conventional suffix '.bundle'
[git/dscho.git] / t / t3301-notes.sh
blob9393a25511f46632763c374fec700c3eb446509e
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 echo "$MSG" > "$1"
12 echo "$MSG" >& 2
13 EOF
14 chmod a+x fake_editor.sh
15 VISUAL=./fake_editor.sh
16 export VISUAL
18 test_expect_success 'cannot annotate non-existing HEAD' '
19 ! MSG=3 git notes edit
22 test_expect_success setup '
23 : > a1 &&
24 git add a1 &&
25 test_tick &&
26 git commit -m 1st &&
27 : > a2 &&
28 git add a2 &&
29 test_tick &&
30 git commit -m 2nd
33 test_expect_success 'need valid notes ref' '
34 ! MSG=1 GIT_NOTES_REF='/' git notes edit &&
35 ! MSG=2 GIT_NOTES_REF='/' git notes show
38 test_expect_success 'create notes' '
39 git config core.notesRef refs/notes/commits &&
40 MSG=b1 git notes edit &&
41 test ! -f .git/new-notes &&
42 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
43 test b1 = $(git notes show) &&
44 git show HEAD^ &&
45 ! git notes show HEAD^
48 cat > expect << EOF
49 commit 268048bfb8a1fb38e703baceb8ab235421bf80c5
50 Author: A U Thor <author@example.com>
51 Date: Thu Apr 7 15:14:13 2005 -0700
53 2nd
55 Notes:
57 EOF
59 test_expect_success 'show notes' '
60 ! (git cat-file commit HEAD | grep b1) &&
61 git log -1 > output &&
62 test_cmp expect output
64 test_expect_success 'create multi-line notes (setup)' '
65 : > a3 &&
66 git add a3 &&
67 test_tick &&
68 git commit -m 3rd &&
69 MSG="b3
70 c3c3c3c3
71 d3d3d3" git notes edit
74 cat > expect-multiline << EOF
75 commit 1584215f1d29c65e99c6c6848626553fdd07fd75
76 Author: A U Thor <author@example.com>
77 Date: Thu Apr 7 15:15:13 2005 -0700
79 3rd
81 Notes:
83 c3c3c3c3
84 d3d3d3
85 EOF
87 printf "\n" >> expect-multiline
88 cat expect >> expect-multiline
90 test_expect_success 'show multi-line notes' '
91 git log -2 > output &&
92 test_cmp expect-multiline output
95 test_done