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:
authorCarlos Martín Nieto <cmn@dwim.me>2013-08-20 13:12:34 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2013-10-02 08:53:24 +0400
commitd274deea23a2c2a70ee1695e8f917dbca50c76b7 (patch)
treef3ddf7a3476ad6ae465d2657a2bbfc3ae6268e7d /src/reflog.c
parentb976f3c2c228413d124be8fea3280a44bd5e3136 (diff)
reflog: add a convenience append function
Provide a function that reads a reflog, performs an append and writes back to the backend in one call.
Diffstat (limited to 'src/reflog.c')
-rw-r--r--src/reflog.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/reflog.c b/src/reflog.c
index c10ae9fd4..923d5a32d 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -158,3 +158,22 @@ int git_reflog_drop(
db = reflog->db;
return db->backend->reflog_drop(db->backend, reflog, idx, rewrite_previous_entry);
}
+
+int git_reflog_append_to(git_repository *repo, const char *name, const git_oid *id,
+ const git_signature *committer, const char *msg)
+{
+ int error;
+ git_reflog *reflog;
+
+ if ((error = git_reflog_read(&reflog, repo, name)) < 0)
+ return error;
+
+ if ((error = git_reflog_append(reflog, id, committer, msg)) < 0)
+ goto cleanup;
+
+ error = git_reflog_write(reflog);
+
+cleanup:
+ git_reflog_free(reflog);
+ return error;
+}