diff options
author | Vicent Marti <tanoku@gmail.com> | 2010-12-07 03:55:46 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2010-12-07 03:55:46 +0200 |
commit | 4eec2c0d4a332ffb9237a0851578ec388e1f99f4 (patch) | |
tree | 6fe3f3bf2e0bd273a8196c8d24dfb5a34d2efced /src/commit.c | |
parent | a44fc1d413bc1e2f0ed82aff60ce2069c33d2eda (diff) | |
download | libgit2-4eec2c0d4a332ffb9237a0851578ec388e1f99f4.tar.gz |
Set short message when changing a commit's messagev0.2.0
Yes, finally.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 16 |
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) |