diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-03-06 23:51:40 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-03-16 16:57:30 +0100 |
commit | 62d38a1ddb8081f8b46e7ff6e21ebeb0014162d6 (patch) | |
tree | 9db11e71533062a0ec6b55e1e767235469390ec0 /src/reset.c | |
parent | d675982a15388d8c413acda139b4662062cf3286 (diff) | |
download | libgit2-62d38a1ddb8081f8b46e7ff6e21ebeb0014162d6.tar.gz |
Add annotated commit versions of reflog-modifying functions
We do not always want to put the id directly into the reflog, but we
want to speicfy what a user typed. For this use-case we provide
annotated version of a few functions which let the caller specify what
user-friendly name was used when asking for the operation.
Diffstat (limited to 'src/reset.c')
-rw-r--r-- | src/reset.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/reset.c b/src/reset.c index 351ecaa2a..aaebf4198 100644 --- a/src/reset.c +++ b/src/reset.c @@ -10,6 +10,7 @@ #include "tag.h" #include "merge.h" #include "diff.h" +#include "annotated_commit.h" #include "git2/reset.h" #include "git2/checkout.h" #include "git2/merge.h" @@ -96,9 +97,10 @@ cleanup: return error; } -int git_reset( +static int reset( git_repository *repo, git_object *target, + const char *to, git_reset_t reset_type, git_checkout_options *checkout_opts) { @@ -139,7 +141,7 @@ int git_reset( goto cleanup; } - if ((error = git_buf_printf(&log_message, "reset: moving to %s", git_oid_tostr_s(git_object_id(commit)))) < 0) + if ((error = git_buf_printf(&log_message, "reset: moving to %s", to)) < 0) return error; /* move HEAD to the new target */ @@ -176,3 +178,21 @@ cleanup: return error; } + +int git_reset( + git_repository *repo, + git_object *target, + git_reset_t reset_type, + git_checkout_options *checkout_opts) +{ + return reset(repo, target, git_oid_tostr_s(git_object_id(target)), reset_type, checkout_opts); +} + +int git_reset_from_annotated( + git_repository *repo, + git_annotated_commit *commit, + git_reset_t reset_type, + git_checkout_options *checkout_opts) +{ + return reset(repo, (git_object *) commit->commit, commit->ref_name, reset_type, checkout_opts); +} |