mirror of
https://git.proxmox.com/git/libgit2
synced 2025-10-17 06:12:28 +00:00
commit: don't forget the last header field
When we moved the logic to handle the first one, wrong loop logic was kept in place which meant we still finished early. But we now notice it because we're not reading past the last LF we find. This was not noticed before as the last field in the tested commit was multi-line which does not trigger the early break.
This commit is contained in:
parent
66ce08a66c
commit
460ae11f0a
@ -568,7 +568,7 @@ int git_commit_header_field(git_buf *out, const git_commit *commit, const char *
|
||||
|
||||
git_buf_sanitize(out);
|
||||
|
||||
while ((eol = strchr(buf, '\n')) && eol[1] != '\0') {
|
||||
while ((eol = strchr(buf, '\n'))) {
|
||||
/* We can skip continuations here */
|
||||
if (buf[0] == ' ') {
|
||||
buf = eol + 1;
|
||||
|
@ -453,10 +453,17 @@ cpxtDQQMGYFpXK/71stq\n\
|
||||
|
||||
cl_git_pass(git_commit_header_field(&buf, commit, "gpgsig"));
|
||||
cl_assert_equal_s(gpgsig, buf.ptr);
|
||||
git_buf_clear(&buf);
|
||||
|
||||
cl_git_fail_with(GIT_ENOTFOUND, git_commit_header_field(&buf, commit, "awesomeness"));
|
||||
cl_git_fail_with(GIT_ENOTFOUND, git_commit_header_field(&buf, commit, "par"));
|
||||
|
||||
git_commit__free(commit);
|
||||
cl_git_pass(parse_commit(&commit, passing_commit_cases[0]));
|
||||
|
||||
cl_git_pass(git_commit_header_field(&buf, commit, "committer"));
|
||||
cl_assert_equal_s("Vicent Marti <tanoku@gmail.com> 1273848544 +0200", buf.ptr);
|
||||
|
||||
git_buf_free(&buf);
|
||||
git_commit__free(commit);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user