mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
trailer: ensure we identify patch lines like git
Git looks explicitly for `---` followed by whitespace (`isspace()`) to determine when a patch line begins in a commit message. Match that behavior. This ensures that we don't treat (say) `----` as a patch line incorrectly.
This commit is contained in:
@@ -158,7 +158,7 @@ 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)
|
||||
if (git__prefixcmp(s, "---") == 0 && git__isspace(s[3]))
|
||||
return s - str;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,3 +165,23 @@ void test_message_trailer__invalid(void)
|
||||
"Another: trailer\n"
|
||||
, trailers);
|
||||
}
|
||||
|
||||
void test_message_trailer__ignores_dashes(void)
|
||||
{
|
||||
git_message_trailer trailers[] = {
|
||||
{ "Signed-off-by", "some@one.com" },
|
||||
{ "Another", "trailer" },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
assert_trailers(
|
||||
"Message\n"
|
||||
"\n"
|
||||
"Markdown header\n"
|
||||
"---------------\n"
|
||||
"Lorem ipsum\n"
|
||||
"\n"
|
||||
"Signed-off-by: some@one.com\n"
|
||||
"Another: trailer\n"
|
||||
, trailers);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user