t3301: verify that 'git notes' removes empty notes by default

Add test cases documenting the current behavior when trying to add/append/edit empty notes. This is in preparation for adding --allow-empty; to allow empty notes to be stored. Improved-by: Eric Sunshine <sunshine@sunshineco.com> Improved-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johan Herland committed Nov 9, 2014 at 13:30 UTC d0923b6d4c01e3c5b86d56b1741292eda7c181fe
1 file changed +27
t/t3301-notes.sh
+27
@@ -1239,4 +1239,31 @@ test_expect_success 'git notes get-ref (--ref)' '
1239 test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz"
1240 '
1241
1242 +test_expect_success 'setup testing of empty notes' '
1243 + test_unconfig core.notesRef &&
1244 + test_commit 16th &&
1245 + empty_blob=$(git hash-object -w /dev/null)
1246 +'
1247 +
1248 +while read cmd
1249 +do
1250 + test_expect_success "'git notes $cmd' removes empty note" "
1251 + test_might_fail git notes remove HEAD &&
1252 + MSG= git notes $cmd &&
1253 + test_must_fail git notes list HEAD
1254 + "
1255 +done <<\EOF
1256 +add
1257 +add -F /dev/null
1258 +add -m ""
1259 +add -c "$empty_blob"
1260 +add -C "$empty_blob"
1261 +append
1262 +append -F /dev/null
1263 +append -m ""
1264 +append -c "$empty_blob"
1265 +append -C "$empty_blob"
1266 +edit
1267 +EOF
1268 +
1269 test_done