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:
authorVicent Marti <tanoku@gmail.com>2010-12-07 04:55:46 +0300
committerVicent Marti <tanoku@gmail.com>2010-12-07 04:55:46 +0300
commit4eec2c0d4a332ffb9237a0851578ec388e1f99f4 (patch)
tree6fe3f3bf2e0bd273a8196c8d24dfb5a34d2efced
parenta44fc1d413bc1e2f0ed82aff60ce2069c33d2eda (diff)
Set short message when changing a commit's messagev0.2.0
Yes, finally. Signed-off-by: Vicent Marti <tanoku@gmail.com>
-rw-r--r--src/commit.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/commit.c b/src/commit.c
index ef3d80b51..d39fc540f 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -292,7 +292,8 @@ void git_commit_set_committer(git_commit *commit, const char *name, const char *
void git_commit_set_message(git_commit *commit, const char *message)
{
- const char *short_message;
+ const char *line_end;
+ size_t message_len;
commit->object.modified = 1;
CHECK_FULL_PARSE();
@@ -304,9 +305,18 @@ void git_commit_set_message(git_commit *commit, const char *message)
free(commit->message_short);
commit->message = git__strdup(message);
- commit->message_short = NULL;
- /* TODO: extract short message */
+ /* Short message */
+ if((line_end = strchr(message, '\n')) == NULL) {
+ commit->message_short = git__strdup(message);
+ return;
+ }
+
+ message_len = line_end - message;
+
+ commit->message_short = git__malloc(message_len + 1);
+ memcpy(commit->message_short, message, message_len);
+ commit->message_short[message_len] = 0;
}
int git_commit_add_parent(git_commit *commit, git_commit *new_parent)