diff options
author | Russell Belfer <rb@github.com> | 2014-02-07 16:14:17 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-02-07 16:14:17 -0800 |
commit | 2d9291943c253e9e1520f87b13abb1e81cffdb29 (patch) | |
tree | 653489f8d29124bb0a6d32d14dfed9d9974bc267 /src/commit.c | |
parent | 57c47af107b45b73a46a1d157f8f758edd536bc7 (diff) | |
parent | db55bb73ff4bccbaccbb4c3a7f6b1fcf09498df7 (diff) | |
download | libgit2-2d9291943c253e9e1520f87b13abb1e81cffdb29.tar.gz |
Merge pull request #2099 from libgit2/bs/more-reflog-stuff
More reflogness
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 730fa6403..d66cf0c6a 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; |