Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Disagreement between git_message_trailers and git-rev-list --format=%(trailers) #6864

Open
@vermiculus

Description

@vermiculus

static size_t find_patch_start(const char *str)
{
const char *s;
for (s = str; *s; s = next_line(s)) {
if (git__prefixcmp(s, "---") == 0 && git__isspace(s[3]))
return s - str;
}
return s - str;
}

Consider this example:

This is a commit message

---

I have more to say here.

Acked-By: General Ackbar <[email protected]>

git_message_trailers does not pick up on the Acked-By trailer whereas git rev-list --format=%(trailers) will. It's notable that git_message_trailers does agree with git-interpret-trailers --divider, but there is no flag to emulate the behavior of --no-divider.

It is possible to work-around this by pre-processing the message to omit the --- line, but this requires a regex match/replace (+ string allocation) unless you get fancy with the char * itself, moving it past the last ---. It would be far nicer if there were options that could be passed to git_message_trailers to simply manipulate this block:

size_t patch_start = find_patch_start(message);
size_t trailer_end = find_trailer_end(message, patch_start);
size_t trailer_start = find_trailer_start(message, trailer_end);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions