Skip to content

Commit 9a1a3a4

Browse files
avargitster
authored andcommitted
mktag: allow omitting the header/body \n separator
Change mktag's acceptance rules to accept an empty body without an empty line after the header again. This fixes an ancient unintended dregression in "mktag". When "mktag" was introduced in ec4465a (Add "tag" objects that can be used to sign other objects., 2005-04-25) the input checks were much looser. When it was documented it 6cfec03 (mktag: minimally update the description., 2007-06-10) it was clearly intended for this \n to be optional: The message, when [it] exists, is separated by a blank line from the header. But then in e0aaf78 (mktag.c: improve verification of tagger field and tests, 2008-03-27) this was made an error, seemingly by accident. It was just a result of the general header checks, and all the tests after that patch have a trailing empty line (but did not before). Let's allow this again, and tweak the test semantics changed in e0aaf78 to remove the redundant empty line. New tests added in previous commits of mine already added an explicit test for allowing the empty line between header and body. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent acfc013 commit 9a1a3a4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fsck.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,8 @@ int fsck_tag_standalone(const struct object_id *oid, const char *buffer,
987987
}
988988
else
989989
ret = fsck_ident(&buffer, oid, OBJ_TAG, options);
990+
if (!*buffer)
991+
goto done;
990992

991993
if (!starts_with(buffer, "\n")) {
992994
/*

t/t3800-mktag.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ tagger T A Gger <[email protected]> 1206478233 -0500
446446
447447
EOF
448448

449-
test_expect_mktag_success 'require a blank line before an empty body (1)'
449+
test_expect_mktag_success 'allow a blank line before an empty body (1)'
450450

451451
cat >tag.sig <<EOF
452452
object $head
@@ -455,8 +455,7 @@ tag mytag
455455
tagger T A Gger <[email protected]> 1206478233 -0500
456456
EOF
457457

458-
check_verify_failure 'require a blank line before an empty body (2)' \
459-
'^error:.* extraHeaderEntry:'
458+
test_expect_mktag_success 'allow no blank line before an empty body (2)'
460459

461460
############################################################
462461
# 24. create valid tag
@@ -466,7 +465,6 @@ object $head
466465
type commit
467466
tag mytag
468467
tagger T A Gger <[email protected]> 1206478233 -0500
469-
470468
EOF
471469

472470
test_expect_mktag_success 'create valid tag object'

0 commit comments

Comments
 (0)