Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-12-02 20:15:27 +0400
committerEdward Thomson <ethomson@edwardthomson.com>2013-12-03 02:57:41 +0400
commit300d192f7ed45112121f2a35d5ca80a4913c7aad (patch)
treea3000995c66950ae009cd3e7f24153bf3683fb78 /src/commit.c
parent14984af6cb9906746d2c64c5df7542ecd7406b16 (diff)
Introduce git_revert to revert a single commit
Diffstat (limited to 'src/commit.c')
-rw-r--r--src/commit.c29
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);