Skip to content

Commit a477abe

Browse files
committed
Merge branch 'mp/for-each-ref-missing-name-or-email'
"for-each-ref" and friends that shows refs did not protect themselves against ancient tags that did not record tagger names when asked to show "%(taggername)", which have been corrected. * mp/for-each-ref-missing-name-or-email: ref-filter: initialize empty name or email fields
2 parents d49c2c3 + 8b3f33e commit a477abe

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

ref-filter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,18 +1028,18 @@ static const char *copy_name(const char *buf)
10281028
if (!strncmp(cp, " <", 2))
10291029
return xmemdupz(buf, cp - buf);
10301030
}
1031-
return "";
1031+
return xstrdup("");
10321032
}
10331033

10341034
static const char *copy_email(const char *buf)
10351035
{
10361036
const char *email = strchr(buf, '<');
10371037
const char *eoemail;
10381038
if (!email)
1039-
return "";
1039+
return xstrdup("");
10401040
eoemail = strchr(email, '>');
10411041
if (!eoemail)
1042-
return "";
1042+
return xstrdup("");
10431043
return xmemdupz(email, eoemail + 1 - email);
10441044
}
10451045

t/t6300-for-each-ref.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,25 @@ test_expect_success 'Check ambiguous head and tag refs II (loose)' '
526526
test_cmp expected actual
527527
'
528528

529+
test_expect_success 'create tag without tagger' '
530+
git tag -a -m "Broken tag" taggerless &&
531+
git tag -f taggerless $(git cat-file tag taggerless |
532+
sed -e "/^tagger /d" |
533+
git hash-object --stdin -w -t tag)
534+
'
535+
536+
test_atom refs/tags/taggerless type 'commit'
537+
test_atom refs/tags/taggerless tag 'taggerless'
538+
test_atom refs/tags/taggerless tagger ''
539+
test_atom refs/tags/taggerless taggername ''
540+
test_atom refs/tags/taggerless taggeremail ''
541+
test_atom refs/tags/taggerless taggerdate ''
542+
test_atom refs/tags/taggerless committer ''
543+
test_atom refs/tags/taggerless committername ''
544+
test_atom refs/tags/taggerless committeremail ''
545+
test_atom refs/tags/taggerless committerdate ''
546+
test_atom refs/tags/taggerless subject 'Broken tag'
547+
529548
test_expect_success 'an unusual tag with an incomplete line' '
530549
531550
git tag -m "bogo" bogo &&

0 commit comments

Comments
 (0)