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@edwardthomson.com>2014-07-19 02:22:54 +0400
committerEdward Thomson <ethomson@microsoft.com>2014-10-27 05:59:27 +0300
commita612a25fa673447e874407fd2d9501998885d392 (patch)
tree57883d4a2ba332246cb0a475c7d0607f091ac72e /src/commit.c
parent517644cce4df8ac9ea40669dd22574d6dc76c02f (diff)
git_rebase_commit: write HEAD's reflog appropriately
Diffstat (limited to 'src/commit.c')
-rw-r--r--src/commit.c36
1 files changed, 5 insertions, 31 deletions
diff --git a/src/commit.c b/src/commit.c
index 227d5c4a5..78c4b9de3 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -16,6 +16,7 @@
#include "commit.h"
#include "signature.h"
#include "message.h"
+#include "refs.h"
void git_commit__free(void *_commit)
{
@@ -34,35 +35,6 @@ void git_commit__free(void *_commit)
git__free(commit);
}
-static int update_ref_for_commit(git_repository *repo, git_reference *ref, const char *update_ref, const git_oid *id, const git_signature *committer)
-{
- git_reference *ref2 = NULL;
- int error;
- git_commit *c;
- const char *shortmsg;
- git_buf reflog_msg = GIT_BUF_INIT;
-
- if ((error = git_commit_lookup(&c, repo, id)) < 0) {
- return 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);
-
- if (ref) {
- error = git_reference_set_target(&ref2, ref, id, committer, git_buf_cstr(&reflog_msg));
- git_reference_free(ref2);
- } else {
- error = git_reference__update_terminal(repo, update_ref, id, committer, git_buf_cstr(&reflog_msg));
- }
-
- git_buf_free(&reflog_msg);
- return error;
-}
-
int git_commit_create_from_callback(
git_oid *id,
git_repository *repo,
@@ -131,7 +103,8 @@ int git_commit_create_from_callback(
git_buf_free(&commit);
if (update_ref != NULL) {
- error = update_ref_for_commit(repo, ref, update_ref, id, committer);
+ error = git_reference__update_for_commit(
+ repo, ref, update_ref, id, committer, "commit");
git_reference_free(ref);
return error;
}
@@ -321,7 +294,8 @@ int git_commit_amend(
&tree_id, commit_parent_for_amend, (void *)commit_to_amend);
if (!error && update_ref) {
- error = update_ref_for_commit(repo, ref, NULL, id, committer);
+ error = git_reference__update_for_commit(
+ repo, ref, NULL, id, committer, "commit");
git_reference_free(ref);
}