diff options
author | Ben Straub <bs@github.com> | 2014-02-04 15:32:57 -0800 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2014-02-04 15:32:57 -0800 |
commit | 0adb06065b944e755933e11ed9ac7ce544b55d33 (patch) | |
tree | 423995d333f9b0586b82bebd8683d86806deda47 /src/commit.c | |
parent | 86746b4b3ae1508c980a7adcdd088ab87a92af7a (diff) | |
download | libgit2-0adb06065b944e755933e11ed9ac7ce544b55d33.tar.gz |
Fix reflog message when creating commits
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/commit.c b/src/commit.c index da7c4992e..b9c21f3cd 100644 --- a/src/commit.c +++ b/src/commit.c @@ -111,8 +111,27 @@ int git_commit_create_from_ids( git_buf_free(&commit); - if (update_ref != NULL) - return git_reference__update_terminal(repo, update_ref, oid, NULL, NULL); + if (update_ref != NULL) { + int error; + git_commit *c; + const char *shortmsg; + git_buf reflog_msg = GIT_BUF_INIT; + + if (git_commit_lookup(&c, repo, oid) < 0) + goto on_error; + + shortmsg = git_commit_summary(c); + git_buf_printf(&reflog_msg, "commit%s: %s", + git_commit_parentcount(c) == 0 ? " (initial)" : "", + shortmsg); + git_commit_free(c); + + error = git_reference__update_terminal(repo, update_ref, oid, + committer, git_buf_cstr(&reflog_msg)); + + git_buf_free(&reflog_msg); + return error; + } return 0; |