diff options
author | Edward Thomson <ethomson@microsoft.com> | 2013-12-02 11:15:27 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2013-12-02 16:57:41 -0600 |
commit | 300d192f7ed45112121f2a35d5ca80a4913c7aad (patch) | |
tree | a3000995c66950ae009cd3e7f24153bf3683fb78 /src/commit.c | |
parent | 14984af6cb9906746d2c64c5df7542ecd7406b16 (diff) | |
download | libgit2-300d192f7ed45112121f2a35d5ca80a4913c7aad.tar.gz |
Introduce git_revert to revert a single commit
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/commit.c b/src/commit.c index 91b60bbb2..bbb76f350 100644 --- a/src/commit.c +++ b/src/commit.c @@ -31,6 +31,7 @@ void git_commit__free(void *_commit) git__free(commit->raw_header); git__free(commit->raw_message); git__free(commit->message_encoding); + git__free(commit->summary); git__free(commit); } @@ -286,6 +287,34 @@ const char *git_commit_message(const git_commit *commit) return message; } +const char *git_commit_summary(git_commit *commit) +{ + git_buf summary = GIT_BUF_INIT; + const char *msg, *space; + + assert(commit); + + if (!commit->summary) { + for (msg = git_commit_message(commit), space = NULL; *msg; ++msg) { + if (msg[0] == '\n' && (!msg[1] || msg[1] == '\n')) + break; + else if (msg[0] == '\n') + git_buf_putc(&summary, ' '); + else if (git__isspace(msg[0])) + space = space ? space : msg; + else if (space) { + git_buf_put(&summary, space, (msg - space) + 1); + space = NULL; + } else + git_buf_putc(&summary, *msg); + } + + commit->summary = git_buf_detach(&summary); + } + + return commit->summary; +} + int git_commit_tree(git_tree **tree_out, const git_commit *commit) { assert(commit); |