notes: empty notes should be shown by 'git log'

If the user has gone through the trouble of explicitly adding an empty note, then "git log" should not silently skip it (as if it didn't exist). Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johan Herland committed Nov 12, 2014 at 01:40 UTC 8a4acd699536c518c9245714d6175aa39d13eb9d
2 files changed +13 -2
notes.c
+1 -2
@@ -1218,8 +1218,7 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,
1218 if (!sha1)
1219 return;
1220
1221 - if (!(msg = read_sha1_file(sha1, &type, &msglen)) || !msglen ||
1222 - type != OBJ_BLOB) {
1221 + if (!(msg = read_sha1_file(sha1, &type, &msglen)) || type != OBJ_BLOB) {
1222 free(msg);
1223 return;
1224 }
t/t3301-notes.sh
+12
@@ -1274,4 +1274,16 @@ append -C "$empty_blob"
1274 edit
1275 EOF
1276
1277 +test_expect_success 'empty notes are displayed by git log' '
1278 + test_commit 17th &&
1279 + git log -1 >expect &&
1280 + cat >>expect <<\EOF &&
1281 +
1282 +Notes:
1283 +EOF
1284 + git notes add -C "$empty_blob" --allow-empty &&
1285 + git log -1 >actual &&
1286 + test_cmp expect actual
1287 +'
1288 +
1289 test_done