54
test_path_is_missing .git/NOTES_EDITMSG &&
55
git ls-tree -r refs/notes/commits >actual &&
56
test_line_count = 1 actual &&
57
- test "b4" = "$(git notes show)" &&
57
+ echo b4 >expect &&
58
+ git notes show >actual &&
59
+ test_cmp expect actual &&
60
git show HEAD^ &&
61
test_must_fail git notes show HEAD^
62
'
81
test_path_is_missing .git/NOTES_EDITMSG &&
82
git ls-tree -r refs/notes/commits >actual &&
83
test_line_count = 1 actual &&
82
- test "b3" = "$(git notes show)" &&
84
+ echo b3 >expect &&
85
+ git notes show >actual &&
86
+ test_cmp expect actual &&
87
git show HEAD^ &&
88
test_must_fail git notes show HEAD^
89
'
90
91
test_expect_success 'show notes from treeish' '
88
- test "b3" = "$(git notes --ref commits^{tree} show)" &&
89
- test "b4" = "$(git notes --ref commits@{1} show)"
92
+ echo b3 >expect &&
93
+ git notes --ref commits^{tree} show >actual &&
94
+ test_cmp expect actual &&
95
+
96
+ echo b4 >expect &&
97
+ git notes --ref commits@{1} show >actual &&
98
+ test_cmp expect actual
99
'
100
101
test_expect_success 'cannot edit notes from non-ref' '
108
test_path_is_missing .git/NOTES_EDITMSG &&
109
git ls-tree -r refs/notes/commits >actual &&
110
test_line_count = 1 actual &&
102
- test "b3" = "$(git notes show)" &&
111
+ echo b3 >expect &&
112
+ git notes show >actual &&
113
+ test_cmp expect actual &&
114
git show HEAD^ &&
115
test_must_fail git notes show HEAD^
116
'
120
test_path_is_missing .git/NOTES_EDITMSG &&
121
git ls-tree -r refs/notes/commits >actual &&
122
test_line_count = 1 actual &&
112
- test "b1" = "$(git notes show)" &&
123
+ echo b1 >expect &&
124
+ git notes show >actual &&
125
+ test_cmp expect actual &&
126
git show HEAD^ &&
127
test_must_fail git notes show HEAD^
128
'
132
test_path_is_missing .git/NOTES_EDITMSG &&
133
git ls-tree -r refs/notes/commits >actual &&
134
test_line_count = 1 actual &&
122
- test "b2" = "$(git notes show)" &&
135
+ echo b2 >expect &&
136
+ git notes show >actual &&
137
+ test_cmp expect actual &&
138
git show HEAD^ &&
139
test_must_fail git notes show HEAD^
140
'
144
test_path_is_missing .git/NOTES_EDITMSG &&
145
git ls-tree -r refs/notes/commits >actual &&
146
test_line_count = 1 actual &&
132
- test "b1" = "$(git notes show)" &&
147
+ echo b1 >expect &&
148
+ git notes show >actual &&
149
+ test_cmp expect actual &&
150
git show HEAD^ &&
151
test_must_fail git notes show HEAD^
152
'
163
Notes:
164
${indent}b1
165
EOF
149
- ! (git cat-file commit HEAD | grep b1) &&
166
+ git cat-file commit HEAD >commits &&
167
+ ! grep b1 commits &&
168
git log -1 >actual &&
169
test_cmp expect actual
170
'
490
test_expect_success 'list notes with "git notes list"' '
491
commit_2=$(git rev-parse 2nd) &&
492
commit_3=$(git rev-parse 3rd) &&
493
+ note_2=$(git rev-parse refs/notes/commits:$commit_2) &&
494
+ note_3=$(git rev-parse refs/notes/commits:$commit_3) &&
495
sort -t" " -k2 >expect <<-EOF &&
476
- $(git rev-parse refs/notes/commits:$commit_2) $commit_2
477
- $(git rev-parse refs/notes/commits:$commit_3) $commit_3
496
+ $note_2 $commit_2
497
+ $note_3 $commit_3
498
EOF
499
git notes list >actual &&
500
test_cmp expect actual
506
'
507
508
test_expect_success 'list specific note with "git notes list <object>"' '
489
- cat >expect <<-EOF &&
490
- $(git rev-parse refs/notes/commits:$commit_3)
491
- EOF
509
+ git rev-parse refs/notes/commits:$commit_3 >expect &&
510
git notes list HEAD^^ >actual &&
511
test_cmp expect actual
512
'
530
531
test_expect_success '"git notes list" does not expand to "git notes list HEAD"' '
532
commit_5=$(git rev-parse 5th) &&
533
+ note_5=$(git rev-parse refs/notes/commits:$commit_5) &&
534
sort -t" " -k2 >expect_list <<-EOF &&
516
- $(git rev-parse refs/notes/commits:$commit_2) $commit_2
517
- $(git rev-parse refs/notes/commits:$commit_3) $commit_3
518
- $(git rev-parse refs/notes/commits:$commit_5) $commit_5
535
+ $note_2 $commit_2
536
+ $note_3 $commit_3
537
+ $note_5 $commit_5
538
EOF
539
git notes list >actual &&
540
test_cmp expect_list actual
740
git notes show HEAD: >actual &&
741
test_cmp expect actual &&
742
echo "Note on a blob" >expect &&
724
- filename=$(git ls-tree --name-only HEAD | head -n1) &&
743
+ git ls-tree --name-only HEAD >files &&
744
+ filename=$(head -n1 files) &&
745
git notes add -m "Note on a blob" HEAD:$filename &&
746
git notes show HEAD:$filename >actual &&
747
test_cmp expect actual &&
765
Notes:
766
${indent}order test
767
EOF
748
- git notes add -C $(git notes list HEAD^) &&
768
+ note=$(git notes list HEAD^) &&
769
+ git notes add -C $note &&
770
git log -1 >actual &&
771
test_cmp expect actual &&
751
- test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
772
+ git notes list HEAD^ >expect &&
773
+ git notes list HEAD >actual &&
774
+ test_cmp expect actual
775
'
776
777
test_expect_success 'create note from non-existing note with "git notes add -C" fails' '
800
Notes:
801
${indent}This is a blob object
802
EOF
780
- blob=$(echo "This is a blob object" | git hash-object -w --stdin) &&
781
- git notes add -C $blob &&
803
+ echo "This is a blob object" | git hash-object -w --stdin >blob &&
804
+ git notes add -C $(cat blob) &&
805
git log -1 >actual &&
806
test_cmp expect actual &&
784
- test "$(git notes list HEAD)" = "$blob"
807
+ git notes list HEAD >actual &&
808
+ test_cmp blob actual
809
'
810
811
test_expect_success 'create note from other note with "git notes add -c"' '
821
Notes:
822
${indent}yet another note
823
EOF
800
- MSG="yet another note" git notes add -c $(git notes list HEAD^^) &&
824
+ note=$(git notes list HEAD^^) &&
825
+ MSG="yet another note" git notes add -c $note &&
826
git log -1 >actual &&
827
test_cmp expect actual
828
'
847
${indent}
848
${indent}yet another note
849
EOF
825
- git notes append -C $(git notes list HEAD^) HEAD^ &&
850
+ note=$(git notes list HEAD^) &&
851
+ git notes append -C $note HEAD^ &&
852
git log -1 HEAD^ >actual &&
853
test_cmp expect actual
854
'
865
Notes:
866
${indent}other note
867
EOF
842
- MSG="other note" git notes append -c $(git notes list HEAD^) &&
868
+ note=$(git notes list HEAD^) &&
869
+ MSG="other note" git notes append -c $note &&
870
git log -1 >actual &&
871
test_cmp expect actual
872
'
885
${indent}
886
${indent}yet another note
887
EOF
861
- MSG="yet another note" git notes append -c $(git notes list HEAD) &&
888
+ note=$(git notes list HEAD) &&
889
+ MSG="yet another note" git notes append -c $note &&
890
git log -1 >actual &&
891
test_cmp expect actual
892
'
906
git notes copy 8th 4th &&
907
git log 3rd..4th >actual &&
908
test_cmp expect actual &&
881
- test "$(git note list 4th)" = "$(git note list 8th)"
909
+ git notes list 4th >expect &&
910
+ git notes list 8th >actual &&
911
+ test_cmp expect actual
912
'
913
914
test_expect_success 'copy note with "git notes copy" with default' '
929
git notes copy HEAD^ &&
930
git log -1 >actual &&
931
test_cmp expect actual &&
902
- test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
932
+ git notes list HEAD^ >expect &&
933
+ git notes list HEAD >actual &&
934
+ test_cmp expect actual
935
'
936
937
test_expect_success 'prevent overwrite with "git notes copy"' '
938
test_must_fail git notes copy HEAD~2 HEAD &&
939
+ cat >expect <<-EOF &&
940
+ commit $commit
941
+ Author: A U Thor <author@example.com>
942
+ Date: Thu Apr 7 15:23:13 2005 -0700
943
+
944
+ ${indent}11th
945
+
946
+ Notes:
947
+ ${indent}other note
948
+ ${indent}
949
+ ${indent}yet another note
950
+ EOF
951
git log -1 >actual &&
952
test_cmp expect actual &&
909
- test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
953
+ git notes list HEAD^ >expect &&
954
+ git notes list HEAD >actual &&
955
+ test_cmp expect actual
956
'
957
958
test_expect_success 'allow overwrite with "git notes copy -f"' '
970
git notes copy -f HEAD~3 HEAD &&
971
git log -1 >actual &&
972
test_cmp expect actual &&
927
- test "$(git notes list HEAD)" = "$(git notes list HEAD~3)"
973
+ git notes list HEAD~3 >expect &&
974
+ git notes list HEAD >actual &&
975
+ test_cmp expect actual
976
'
977
978
test_expect_success 'allow overwrite with "git notes copy -f" with default' '
992
git notes copy -f HEAD~2 &&
993
git log -1 >actual &&
994
test_cmp expect actual &&
947
- test "$(git notes list HEAD)" = "$(git notes list HEAD~2)"
995
+ git notes list HEAD~2 >expect &&
996
+ git notes list HEAD >actual &&
997
+ test_cmp expect actual
998
'
999
1000
test_expect_success 'cannot copy note from object without notes' '
1029
${indent}
1030
${indent}yet another note
1031
EOF
982
- (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) &&
983
- echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
984
- git notes copy --stdin &&
1032
+ from=$(git rev-parse HEAD~3) &&
1033
+ to=$(git rev-parse HEAD^) &&
1034
+ echo "$from" "$to" >copy &&
1035
+ from=$(git rev-parse HEAD~2) &&
1036
+ to=$(git rev-parse HEAD) &&
1037
+ echo "$from" "$to" >>copy &&
1038
+ git notes copy --stdin <copy &&
1039
git log -2 >actual &&
1040
test_cmp expect actual &&
987
- test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
988
- test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
1041
+ git notes list HEAD~2 >expect &&
1042
+ git notes list HEAD >actual &&
1043
+ test_cmp expect actual &&
1044
+ git notes list HEAD~3 >expect &&
1045
+ git notes list HEAD^ >actual &&
1046
+ test_cmp expect actual
1047
'
1048
1049
test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
1064
1065
${indent}14th
1066
EOF
1009
- (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) &&
1010
- echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
1011
- git notes copy --for-rewrite=foo &&
1067
+ from=$(git rev-parse HEAD~3) &&
1068
+ to=$(git rev-parse HEAD^) &&
1069
+ echo "$from" "$to" >copy &&
1070
+ from=$(git rev-parse HEAD~2) &&
1071
+ to=$(git rev-parse HEAD) &&
1072
+ echo "$from" "$to" >>copy &&
1073
+ git notes copy --for-rewrite=foo <copy &&
1074
git log -2 >actual &&
1075
test_cmp expect actual
1076
'
1103
EOF
1104
test_config notes.rewriteMode overwrite &&
1105
test_config notes.rewriteRef "refs/notes/*" &&
1044
- (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) &&
1045
- echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
1046
- git notes copy --for-rewrite=foo &&
1106
+ from=$(git rev-parse HEAD~3) &&
1107
+ to=$(git rev-parse HEAD^) &&
1108
+ echo "$from" "$to" >copy &&
1109
+ from=$(git rev-parse HEAD~2) &&
1110
+ to=$(git rev-parse HEAD) &&
1111
+ echo "$from" "$to" >>copy &&
1112
+ git notes copy --for-rewrite=foo <copy &&
1113
git log -2 >actual &&
1114
test_cmp expect actual
1115
'
1116
1117
test_expect_success 'git notes copy --for-rewrite (disabled)' '
1118
test_config notes.rewrite.bar false &&
1053
- echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
1054
- git notes copy --for-rewrite=bar &&
1119
+ from=$(git rev-parse HEAD~3) &&
1120
+ to=$(git rev-parse HEAD) &&
1121
+ echo "$from" "$to" >copy &&
1122
+ git notes copy --for-rewrite=bar <copy &&
1123
git log -2 >actual &&
1124
test_cmp expect actual
1125
'
1139
git notes add -f -m"a fresh note" HEAD^ &&
1140
test_config notes.rewriteMode overwrite &&
1141
test_config notes.rewriteRef "refs/notes/*" &&
1074
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1075
- git notes copy --for-rewrite=foo &&
1142
+ from=$(git rev-parse HEAD^) &&
1143
+ to=$(git rev-parse HEAD) &&
1144
+ echo "$from" "$to" >copy &&
1145
+ git notes copy --for-rewrite=foo <copy &&
1146
git log -1 >actual &&
1147
test_cmp expect actual
1148
'
1150
test_expect_success 'git notes copy --for-rewrite (ignore)' '
1151
test_config notes.rewriteMode ignore &&
1152
test_config notes.rewriteRef "refs/notes/*" &&
1083
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1084
- git notes copy --for-rewrite=foo &&
1153
+ from=$(git rev-parse HEAD^) &&
1154
+ to=$(git rev-parse HEAD) &&
1155
+ echo "$from" "$to" >copy &&
1156
+ git notes copy --for-rewrite=foo <copy &&
1157
git log -1 >actual &&
1158
test_cmp expect actual
1159
'
1175
git notes add -f -m"another fresh note" HEAD^ &&
1176
test_config notes.rewriteMode concatenate &&
1177
test_config notes.rewriteRef "refs/notes/*" &&
1106
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1107
- git notes copy --for-rewrite=foo &&
1178
+ from=$(git rev-parse HEAD^) &&
1179
+ to=$(git rev-parse HEAD) &&
1180
+ echo "$from" "$to" >copy &&
1181
+ git notes copy --for-rewrite=foo <copy &&
1182
git log -1 >actual &&
1183
test_cmp expect actual
1184
'
1205
git notes add -f -m"append 2" HEAD^^ &&
1206
test_config notes.rewriteMode concatenate &&
1207
test_config notes.rewriteRef "refs/notes/*" &&
1134
- (echo $(git rev-parse HEAD^) $(git rev-parse HEAD) &&
1135
- echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
1136
- git notes copy --for-rewrite=foo &&
1208
+ from=$(git rev-parse HEAD^) &&
1209
+ to=$(git rev-parse HEAD) &&
1210
+ echo "$from" "$to" >copy &&
1211
+ from=$(git rev-parse HEAD^^) &&
1212
+ to=$(git rev-parse HEAD) &&
1213
+ echo "$from" "$to" >>copy &&
1214
+ git notes copy --for-rewrite=foo <copy &&
1215
git log -1 >actual &&
1216
test_cmp expect actual
1217
'
1220
git notes remove HEAD^ &&
1221
test_config notes.rewriteMode concatenate &&
1222
test_config notes.rewriteRef "refs/notes/*" &&
1145
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1146
- git notes copy --for-rewrite=foo &&
1223
+ from=$(git rev-parse HEAD^) &&
1224
+ to=$(git rev-parse HEAD) &&
1225
+ echo "$from" "$to" >copy &&
1226
+ git notes copy --for-rewrite=foo <copy &&
1227
git log -1 >actual &&
1228
test_cmp expect actual
1229
'
1243
test_config notes.rewriteMode concatenate &&
1244
test_config notes.rewriteRef "refs/notes/*" &&
1245
git notes add -f -m"replacement note 1" HEAD^ &&
1166
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1167
- GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
1246
+ from=$(git rev-parse HEAD^) &&
1247
+ to=$(git rev-parse HEAD) &&
1248
+ echo "$from" "$to" >copy &&
1249
+ GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo <copy &&
1250
git log -1 >actual &&
1251
test_cmp expect actual
1252
'
1266
git notes add -f -m"replacement note 2" HEAD^ &&
1267
test_config notes.rewriteMode overwrite &&
1268
test_unconfig notes.rewriteRef &&
1187
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1269
+ from=$(git rev-parse HEAD^) &&
1270
+ to=$(git rev-parse HEAD) &&
1271
+ echo "$from" "$to" >copy &&
1272
GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
1189
- git notes copy --for-rewrite=foo &&
1273
+ git notes copy --for-rewrite=foo <copy &&
1274
git log -1 >actual &&
1275
test_cmp expect actual
1276
'
1279
git notes add -f -m"replacement note 3" HEAD^ &&
1280
test_config notes.rewriteMode overwrite &&
1281
test_config notes.rewriteRef refs/notes/other &&
1198
- echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1282
+ from=$(git rev-parse HEAD^) &&
1283
+ to=$(git rev-parse HEAD) &&
1284
+ echo "$from" "$to" >copy &&
1285
GIT_NOTES_REWRITE_REF=refs/notes/commits \
1200
- git notes copy --for-rewrite=foo &&
1286
+ git notes copy --for-rewrite=foo <copy &&
1287
git log -1 >actual &&
1288
grep "replacement note 3" actual
1289
'
1298
test_expect_success 'git notes get-ref expands refs/heads/master to refs/notes/refs/heads/master' '
1299
test_unconfig core.notesRef &&
1300
sane_unset GIT_NOTES_REF &&
1215
- test "$(git notes --ref=refs/heads/master get-ref)" = "refs/notes/refs/heads/master"
1301
+ echo refs/notes/refs/heads/master >expect &&
1302
+ git notes --ref=refs/heads/master get-ref >actual &&
1303
+ test_cmp expect actual
1304
'
1305
1306
test_expect_success 'git notes get-ref (no overrides)' '
1307
test_unconfig core.notesRef &&
1308
sane_unset GIT_NOTES_REF &&
1221
- test "$(git notes get-ref)" = "refs/notes/commits"
1309
+ echo refs/notes/commits >expect &&
1310
+ git notes get-ref >actual &&
1311
+ test_cmp expect actual
1312
'
1313
1314
test_expect_success 'git notes get-ref (core.notesRef)' '
1315
test_config core.notesRef refs/notes/foo &&
1226
- test "$(git notes get-ref)" = "refs/notes/foo"
1316
+ echo refs/notes/foo >expect &&
1317
+ git notes get-ref >actual &&
1318
+ test_cmp expect actual
1319
'
1320
1321
test_expect_success 'git notes get-ref (GIT_NOTES_REF)' '
1230
- test "$(GIT_NOTES_REF=refs/notes/bar git notes get-ref)" = "refs/notes/bar"
1322
+ echo refs/notes/bar >expect &&
1323
+ GIT_NOTES_REF=refs/notes/bar git notes get-ref >actual &&
1324
+ test_cmp expect actual
1325
'
1326
1327
test_expect_success 'git notes get-ref (--ref)' '
1234
- test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz"
1328
+ echo refs/notes/baz >expect &&
1329
+ GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref >actual &&
1330
+ test_cmp expect actual
1331
'
1332
1333
test_expect_success 'setup testing of empty notes' '