Skip to content

Commit 8a4acd6

Browse files
jherlandgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d73a5b9 commit 8a4acd6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

notes.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,7 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,
12181218
if (!sha1)
12191219
return;
12201220

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) {
12231222
free(msg);
12241223
return;
12251224
}

t/t3301-notes.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,4 +1274,16 @@ append -C "$empty_blob"
12741274
edit
12751275
EOF
12761276

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+
12771289
test_done

0 commit comments

Comments
 (0)