Merge pull request #2072 from ethomson/commit_summary

Summarize empty messages
This commit is contained in:
Vicent Marti 2014-01-22 11:50:43 -08:00
commit e82b6d13d2
2 changed files with 8 additions and 1 deletions

View File

@ -311,7 +311,10 @@ const char *git_commit_summary(git_commit *commit)
git_buf_putc(&summary, *msg);
}
commit->summary = git_buf_detach(&summary);
if (summary.asize == 0)
commit->summary = git__strdup("");
else
commit->summary = git_buf_detach(&summary);
}
return commit->summary;

View File

@ -72,4 +72,8 @@ void test_commit_commit__summary(void)
assert_commit_summary("Trailing spaces are removed", "Trailing spaces are removed ");
assert_commit_summary("Trailing tabs", "Trailing tabs\t\n\nare removed");
assert_commit_summary("Trailing spaces", "Trailing spaces \n\nare removed");
assert_commit_summary("", "");
assert_commit_summary("", " ");
assert_commit_summary("", "\n");
assert_commit_summary("", "\n \n");
}