16
export GIT_EDITOR
17
18
test_expect_success 'cannot annotate non-existing HEAD' '
19
- (MSG=3 && export MSG && test_must_fail git notes edit)
19
+ (MSG=3 && export MSG && test_must_fail git notes add)
20
'
21
22
test_expect_success setup '
32
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) &&
35
+ test_must_fail git notes add) &&
36
(MSG=2 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
37
test_must_fail git notes show)
38
'
39
40
-test_expect_success 'refusing to edit in refs/heads/' '
40
+test_expect_success 'refusing to add notes 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)
43
+ test_must_fail git notes add)
44
'
45
46
-test_expect_success 'refusing to edit in refs/remotes/' '
46
+test_expect_success 'refusing to edit notes 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)
56
57
test_expect_success 'create notes' '
58
git config core.notesRef refs/notes/commits &&
59
- MSG=b0 git notes edit &&
59
+ MSG=b4 git notes add &&
60
test ! -f .git/NOTES_EDITMSG &&
61
test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
62
- test b0 = $(git notes show) &&
62
+ test b4 = $(git notes show) &&
63
git show HEAD^ &&
64
test_must_fail git notes show HEAD^
65
'
66
67
test_expect_success 'edit existing notes' '
68
- MSG=b1 git notes edit &&
68
+ MSG=b3 git notes edit &&
69
+ test ! -f .git/NOTES_EDITMSG &&
70
+ test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
71
+ test b3 = $(git notes show) &&
72
+ git show HEAD^ &&
73
+ test_must_fail git notes show HEAD^
74
+'
75
+
76
+test_expect_success 'cannot add note where one exists' '
77
+ ! MSG=b2 git notes add &&
78
+ test ! -f .git/NOTES_EDITMSG &&
79
+ test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
80
+ test b3 = $(git notes show) &&
81
+ git show HEAD^ &&
82
+ test_must_fail git notes show HEAD^
83
+'
84
+
85
+test_expect_success 'can overwrite existing note with "git notes add -f"' '
86
+ MSG=b1 git notes add -f &&
87
test ! -f .git/NOTES_EDITMSG &&
88
test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
89
test b1 = $(git notes show) &&
107
git log -1 > output &&
108
test_cmp expect output
109
'
110
+
111
test_expect_success 'create multi-line notes (setup)' '
112
: > a3 &&
113
git add a3 &&
115
git commit -m 3rd &&
116
MSG="b3
117
c3c3c3c3
99
-d3d3d3" git notes edit
118
+d3d3d3" git notes add
119
'
120
121
cat > expect-multiline << EOF
144
test_tick &&
145
git commit -m 4th &&
146
echo "xyzzy" > note5 &&
128
- git notes edit -F note5
147
+ git notes add -F note5
148
'
149
150
cat > expect-F << EOF
224
git add a5 &&
225
test_tick &&
226
git commit -m 5th &&
208
- git notes edit -m spam -m "foo
227
+ git notes add -m spam -m "foo
228
bar
229
baz"
230
'
253
test_cmp expect-m output
254
'
255
237
-test_expect_success 'remove note with -F /dev/null (setup)' '
238
- git notes edit -F /dev/null
256
+test_expect_success 'remove note with add -f -F /dev/null (setup)' '
257
+ git notes add -f -F /dev/null
258
'
259
260
cat > expect-rm-F << EOF
275
'
276
277
test_expect_success 'do not create empty note with -m "" (setup)' '
259
- git notes edit -m ""
278
+ git notes add -m ""
279
'
280
281
test_expect_success 'verify non-creation of note with -m ""' '
348
git add a6 &&
349
test_tick &&
350
git commit -m 6th &&
332
- GIT_NOTES_REF="refs/notes/other" git notes edit -m "other note"
351
+ GIT_NOTES_REF="refs/notes/other" git notes add -m "other note"
352
'
353
354
cat > expect-other << EOF
393
394
test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' '
395
echo "Note on a tree" > expect
377
- git notes edit -m "Note on a tree" HEAD: &&
396
+ git notes add -m "Note on a tree" HEAD: &&
397
git notes show HEAD: > actual &&
398
test_cmp expect actual &&
399
echo "Note on a blob" > expect
400
filename=$(git ls-tree --name-only HEAD | head -n1) &&
382
- git notes edit -m "Note on a blob" HEAD:$filename &&
401
+ git notes add -m "Note on a blob" HEAD:$filename &&
402
git notes show HEAD:$filename > actual &&
403
test_cmp expect actual &&
404
echo "Note on a tag" > expect
405
git tag -a -m "This is an annotated tag" foobar HEAD^ &&
387
- git notes edit -m "Note on a tag" foobar &&
406
+ git notes add -m "Note on a tag" foobar &&
407
git notes show foobar > actual &&
408
test_cmp expect actual
409
'