Commit 238e8149 by Edward Thomson

Summarize empty messages

parent 2b678ce5
...@@ -311,7 +311,10 @@ const char *git_commit_summary(git_commit *commit) ...@@ -311,7 +311,10 @@ const char *git_commit_summary(git_commit *commit)
git_buf_putc(&summary, *msg); 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; return commit->summary;
......
...@@ -72,4 +72,8 @@ void test_commit_commit__summary(void) ...@@ -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 spaces are removed", "Trailing spaces are removed ");
assert_commit_summary("Trailing tabs", "Trailing tabs\t\n\nare 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("Trailing spaces", "Trailing spaces \n\nare removed");
assert_commit_summary("", "");
assert_commit_summary("", " ");
assert_commit_summary("", "\n");
assert_commit_summary("", "\n \n");
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment