path: root/t/
diff options
authorJohan Herland <>2014-11-12 00:40:14 (GMT)
committerJunio C Hamano <>2014-11-12 19:00:11 (GMT)
commitd73a5b933db1e722faa54d6709e89e2450d7c1e3 (patch)
tree758422932df86d91545398515278e7192749937d /t/
parent52694cdabbf68f19c8289416e7bb3bbef41d8d27 (diff)
builtin/notes: add --allow-empty, to allow storing empty notes
Although the "git notes" man page advertises that we support binary-safe notes addition (using the -C option), we currently do not support adding the empty note (i.e. using the empty blob to annotate an object). Instead, an empty note is always treated as an intent to remove the note altogether. Introduce the --allow-empty option to the add/append/edit subcommands, to explicitly allow an empty note to be stored into the notes tree. Also update the documentation, and add test cases for the new option. Reported-by: James H. Fisher <> Improved-by: Kyle J. McKay <> Improved-by: Junio C Hamano <> Signed-off-by: Johan Herland <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 9 insertions, 1 deletions
diff --git a/t/ b/t/
index f74b3fa..70ec5c3 100755
--- a/t/
+++ b/t/
@@ -1242,7 +1242,8 @@ test_expect_success 'git notes get-ref (--ref)' '
test_expect_success 'setup testing of empty notes' '
test_unconfig core.notesRef &&
test_commit 16th &&
- empty_blob=$(git hash-object -w /dev/null)
+ empty_blob=$(git hash-object -w /dev/null) &&
+ echo "$empty_blob" >expect_empty
while read cmd
@@ -1252,6 +1253,13 @@ do
MSG= git notes $cmd &&
test_must_fail git notes list HEAD
+ test_expect_success "'git notes $cmd --allow-empty' stores empty note" "
+ test_might_fail git notes remove HEAD &&
+ MSG= git notes $cmd --allow-empty &&
+ git notes list HEAD >actual &&
+ test_cmp expect_empty actual
+ "
done <<\EOF
add -F /dev/null