diff options
author | Vicent Marti <vicent@github.com> | 2014-01-22 11:50:43 -0800 |
---|---|---|
committer | Vicent Marti <vicent@github.com> | 2014-01-22 11:50:43 -0800 |
commit | e82b6d13d21c99eb95ae6721eb0e89101c3256c4 (patch) | |
tree | b251bc295ef08aef080ceabbac10f5dd9924b724 | |
parent | 2b678ce5b4ebbc1d045f2a07651720d8c1e6458c (diff) | |
parent | 238e8149724ea462153cc082385f60dccc2a3cf9 (diff) | |
download | libgit2-e82b6d13d21c99eb95ae6721eb0e89101c3256c4.tar.gz |
Merge pull request #2072 from ethomson/commit_summary
Summarize empty messages
-rw-r--r-- | src/commit.c | 5 | ||||
-rw-r--r-- | tests/commit/commit.c | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/commit.c b/src/commit.c index f0e304a84..e437cffe6 100644 --- a/src/commit.c +++ b/src/commit.c @@ -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; diff --git a/tests/commit/commit.c b/tests/commit/commit.c index 4af9190b5..38397d2df 100644 --- a/tests/commit/commit.c +++ b/tests/commit/commit.c @@ -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"); } |