32
test_cmp expect actual
33
'
34
35
-test_expect_success 'add note by specifying single "-m"' '
35
+test_expect_success 'add note by specifying single "-m", "--stripspace" is the default behavior' '
36
test_when_finished "git notes remove" &&
37
cat >expect <<-EOF &&
38
first-line
42
43
git notes add -m "${LF}first-line${MULTI_LF}second-line${LF}" &&
44
git notes show >actual &&
45
+ test_cmp expect actual &&
46
+ git notes remove &&
47
+ git notes add --stripspace -m "${LF}first-line${MULTI_LF}second-line${LF}" &&
48
+ git notes show >actual &&
49
test_cmp expect actual
50
'
51
48
-test_expect_success 'add note by specifying multiple "-m"' '
52
+test_expect_success 'add note by specifying single "-m" and "--no-stripspace" ' '
53
+ test_when_finished "git notes remove" &&
54
+ cat >expect <<-EOF &&
55
+ ${LF}first-line${MULTI_LF}second-line
56
+ EOF
57
+
58
+ git notes add --no-stripspace \
59
+ -m "${LF}first-line${MULTI_LF}second-line${LF}" &&
60
+ git notes show >actual &&
61
+ test_cmp expect actual
62
+'
63
+
64
+test_expect_success 'add note by specifying multiple "-m", "--stripspace" is the default behavior' '
65
test_when_finished "git notes remove" &&
66
cat >expect <<-EOF &&
67
first-line
75
-m "second-line" \
76
-m "${LF}" &&
77
git notes show >actual &&
78
+ test_cmp expect actual &&
79
+ git notes remove &&
80
+ git notes add --stripspace -m "${LF}" \
81
+ -m "first-line" \
82
+ -m "${MULTI_LF}" \
83
+ -m "second-line" \
84
+ -m "${LF}" &&
85
+ git notes show >actual &&
86
test_cmp expect actual
87
'
88
89
+test_expect_success 'add notes by specifying multiple "-m" and "--no-stripspace"' '
90
+ test_when_finished "git notes remove" &&
91
+ cat >expect <<-EOF &&
92
+ ${LF}
93
+ first-line
94
+ ${MULTI_LF}
95
+ second-line${LF}
96
+ EOF
97
+
98
+ git notes add --no-stripspace \
99
+ -m "${LF}" \
100
+ -m "first-line" \
101
+ -m "${MULTI_LF}" \
102
+ -m "second-line" \
103
+ -m "${LF}" &&
104
+ git notes show >actual &&
105
+ test_cmp expect actual
106
+'
107
+
108
+test_expect_success 'add note by specifying single "-F", "--stripspace" is the default behavior' '
109
+ test_when_finished "git notes remove" &&
110
+ cat >expect <<-EOF &&
111
+ first-line
112
+
113
+ second-line
114
+ EOF
115
+
116
+ cat >note-file <<-EOF &&
117
+ ${LF}
118
+ first-line
119
+ ${MULTI_LF}
120
+ second-line
121
+ ${LF}
122
+ EOF
123
+
124
+ git notes add -F note-file &&
125
+ git notes show >actual &&
126
+ test_cmp expect actual &&
127
+ git notes remove &&
128
+ git notes add --stripspace -F note-file &&
129
+ git notes show >actual
130
+'
131
+
132
+test_expect_success 'add note by specifying single "-F" and "--no-stripspace"' '
133
+ test_when_finished "git notes remove" &&
134
+ cat >expect <<-EOF &&
135
+ ${LF}
136
+ first-line
137
+ ${MULTI_LF}
138
+ second-line
139
+ ${LF}
140
+ EOF
141
+
142
+ cat >note-file <<-EOF &&
143
+ ${LF}
144
+ first-line
145
+ ${MULTI_LF}
146
+ second-line
147
+ ${LF}
148
+ EOF
149
+
150
+ git notes add --no-stripspace -F note-file &&
151
+ git notes show >actual &&
152
+ test_cmp expect actual
153
+'
154
+
155
+test_expect_success 'add note by specifying multiple "-F", "--stripspace" is the default behavior' '
156
+ test_when_finished "git notes remove" &&
157
+ cat >expect <<-EOF &&
158
+ file-1-first-line
159
+
160
+ file-1-second-line
161
+
162
+ file-2-first-line
163
+
164
+ file-2-second-line
165
+ EOF
166
+
167
+ cat >note-file-1 <<-EOF &&
168
+ ${LF}
169
+ file-1-first-line
170
+ ${MULTI_LF}
171
+ file-1-second-line
172
+ ${LF}
173
+ EOF
174
+
175
+ cat >note-file-2 <<-EOF &&
176
+ ${LF}
177
+ file-2-first-line
178
+ ${MULTI_LF}
179
+ file-2-second-line
180
+ ${LF}
181
+ EOF
182
+
183
+ git notes add -F note-file-1 -F note-file-2 &&
184
+ git notes show >actual &&
185
+ test_cmp expect actual &&
186
+ git notes remove &&
187
+ git notes add --stripspace -F note-file-1 -F note-file-2 &&
188
+ git notes show >actual &&
189
+ test_cmp expect actual
190
+'
191
+
192
+test_expect_success 'add note by specifying multiple "-F" with "--no-stripspace"' '
193
+ test_when_finished "git notes remove" &&
194
+ cat >expect <<-EOF &&
195
+ ${LF}
196
+ file-1-first-line
197
+ ${MULTI_LF}
198
+ file-1-second-line
199
+ ${LF}
200
+
201
+ ${LF}
202
+ file-2-first-line
203
+ ${MULTI_LF}
204
+ file-2-second-line
205
+ ${LF}
206
+ EOF
207
+
208
+ cat >note-file-1 <<-EOF &&
209
+ ${LF}
210
+ file-1-first-line
211
+ ${MULTI_LF}
212
+ file-1-second-line
213
+ ${LF}
214
+ EOF
215
+
216
+ cat >note-file-2 <<-EOF &&
217
+ ${LF}
218
+ file-2-first-line
219
+ ${MULTI_LF}
220
+ file-2-second-line
221
+ ${LF}
222
+ EOF
223
+
224
+ git notes add --no-stripspace -F note-file-1 -F note-file-2 &&
225
+ git notes show >actual &&
226
+ test_cmp expect actual
227
+'
228
229
test_expect_success 'append note by editor' '
230
test_when_finished "git notes remove" &&
384
test_cmp expect actual
385
'
386
387
+test_expect_success 'append note by specifying multiple "-F" with "--no-stripspace"' '
388
+ test_when_finished "git notes remove" &&
389
+ cat >expect <<-EOF &&
390
+ initial-line
391
+ ${LF}${LF}
392
+ file-1-first-line
393
+ ${MULTI_LF}
394
+ file-1-second-line
395
+ ${LF}
396
+
397
+ ${LF}
398
+ file-2-first-line
399
+ ${MULTI_LF}
400
+ file-2-second-line
401
+ ${LF}
402
+ EOF
403
+
404
+ cat >note-file-1 <<-EOF &&
405
+ ${LF}
406
+ file-1-first-line
407
+ ${MULTI_LF}
408
+ file-1-second-line
409
+ ${LF}
410
+ EOF
411
+
412
+ cat >note-file-2 <<-EOF &&
413
+ ${LF}
414
+ file-2-first-line
415
+ ${MULTI_LF}
416
+ file-2-second-line
417
+ ${LF}
418
+ EOF
419
+
420
+ git notes add -m "initial-line" &&
421
+ git notes append --no-stripspace -F note-file-1 -F note-file-2 &&
422
+ git notes show >actual &&
423
+ test_cmp expect actual
424
+'
425
+
426
test_expect_success 'add notes with empty messages' '
427
rev=$(git rev-parse HEAD) &&
428
git notes add -m "${LF}" \
431
test_i18ngrep "Removing note for object" actual
432
'
433
232
-test_expect_success 'add note by specifying "-C" , do not stripspace is the default behavior' '
434
+test_expect_success 'add note by specifying "-C", "--no-stripspace" is the default behavior' '
435
test_when_finished "git notes remove" &&
436
cat >expect <<-EOF &&
437
${LF}
444
cat expect | git hash-object -w --stdin >blob &&
445
git notes add -C $(cat blob) &&
446
git notes show >actual &&
447
+ test_cmp expect actual &&
448
+ git notes remove &&
449
+ git notes add --no-stripspace -C $(cat blob) &&
450
+ git notes show >actual &&
451
+ test_cmp expect actual
452
+'
453
+
454
+test_expect_success 'reuse note by specifying "-C" and "--stripspace"' '
455
+ test_when_finished "git notes remove" &&
456
+ cat >data <<-EOF &&
457
+ ${LF}
458
+ first-line
459
+ ${MULTI_LF}
460
+ second-line
461
+ ${LF}
462
+ EOF
463
+
464
+ cat >expect <<-EOF &&
465
+ first-line
466
+
467
+ second-line
468
+ EOF
469
+
470
+ cat data | git hash-object -w --stdin >blob &&
471
+ git notes add --stripspace -C $(cat blob) &&
472
+ git notes show >actual &&
473
test_cmp expect actual
474
'
475
248
-test_expect_success 'add notes with "-C" and "-m", "-m" will stripspace all together' '
476
+test_expect_success 'reuse with "-C" and add note with "-m", "-m" will stripspace all together' '
477
test_when_finished "git notes remove" &&
478
cat >data <<-EOF &&
479
${LF}
497
test_cmp expect actual
498
'
499
272
-test_expect_success 'add notes with "-m" and "-C", "-C" will not stripspace all together' '
500
+test_expect_success 'add note with "-m" and reuse note with "-C", "-C" will not stripspace all together' '
501
test_when_finished "git notes remove" &&
502
cat >data <<-EOF &&
503
516
test_cmp expect actual
517
'
518
519
+test_expect_success 'add note by specifying "-c", "--stripspace" is the default behavior' '
520
+ test_when_finished "git notes remove" &&
521
+ cat >expect <<-EOF &&
522
+ first-line
523
+
524
+ second-line
525
+ EOF
526
+
527
+ echo "initial-line" | git hash-object -w --stdin >blob &&
528
+ MSG="${LF}first-line${MULTI_LF}second-line${LF}" git notes add -c $(cat blob) &&
529
+ git notes show >actual &&
530
+ test_cmp expect actual &&
531
+ git notes remove &&
532
+ MSG="${LF}first-line${MULTI_LF}second-line${LF}" git notes add --stripspace -c $(cat blob) &&
533
+ git notes show >actual &&
534
+ test_cmp expect actual
535
+'
536
+
537
+test_expect_success 'add note by specifying "-c" with "--no-stripspace"' '
538
+ test_when_finished "git notes remove" &&
539
+ cat >expect <<-EOF &&
540
+ ${LF}first-line${MULTI_LF}second-line${LF}
541
+ EOF
542
+
543
+ echo "initial-line" | git hash-object -w --stdin >blob &&
544
+ MSG="${LF}first-line${MULTI_LF}second-line${LF}" git notes add --no-stripspace -c $(cat blob) &&
545
+ git notes show >actual &&
546
+ test_cmp expect actual
547
+'
548
+
549
+test_expect_success 'edit note by specifying "-c", "--stripspace" is the default behavior' '
550
+ test_when_finished "git notes remove" &&
551
+ cat >expect <<-EOF &&
552
+ first-line
553
+
554
+ second-line
555
+ EOF
556
+
557
+ MSG="${LF}first-line${MULTI_LF}second-line${LF}" git notes edit &&
558
+ git notes show >actual &&
559
+ test_cmp expect actual &&
560
+ git notes remove &&
561
+ MSG="${LF}first-line${MULTI_LF}second-line${LF}" git notes edit --stripspace &&
562
+ git notes show >actual &&
563
+ test_cmp expect actual
564
+'
565
+
566
+test_expect_success 'edit note by specifying "-c" with "--no-stripspace"' '
567
+ test_when_finished "git notes remove" &&
568
+ cat >expect <<-EOF &&
569
+ ${LF}first-line${MULTI_LF}second-line${LF}
570
+ EOF
571
+
572
+ MSG="${LF}first-line${MULTI_LF}second-line${LF}" git notes add --no-stripspace &&
573
+ git notes show >actual &&
574
+ test_cmp expect actual
575
+'
576
+
577
test_done