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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libgit2/trailer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
31 changes: 27 additions & 4 deletions tests/libgit2/message/trailer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
static void assert_trailers(const char *message, git_message_trailer *trailers)
{
git_message_trailer_array arr;
size_t i;
size_t i, count;

int rc = git_message_trailers(&arr, message);

cl_assert_equal_i(0, rc);

for(i=0; i<arr.count; i++) {
for (i = 0, count = 0; trailers[i].key != NULL; i++, count++)
;

cl_assert_equal_sz(arr.count, count);

for (i=0; i < count; i++) {
cl_assert_equal_s(arr.trailers[i].key, trailers[i].key);
cl_assert_equal_s(arr.trailers[i].value, trailers[i].value);
}

cl_assert_equal_i(0, rc);

git_message_trailer_array_free(&arr);
}

Expand Down Expand Up @@ -162,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", "[email protected]" },
{ "Another", "trailer" },
{ NULL, NULL },
};

assert_trailers(
"Message\n"
"\n"
"Markdown header\n"
"---------------\n"
"Lorem ipsum\n"
"\n"
"Signed-off-by: [email protected]\n"
"Another: trailer\n"
, trailers);
}