reset: make reset rely on git_repository_head()
diff --git a/src/reset.c b/src/reset.c
index 4ce21e2..c536e75 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -29,6 +29,7 @@ int git_reset(
git_tree *tree = NULL;
int error = -1;
git_checkout_opts opts;
+ git_reference *head = NULL;
assert(repo && target);
assert(reset_type == GIT_RESET_SOFT
@@ -49,7 +50,10 @@ int git_reset(
//TODO: Check for unmerged entries
- if (git_reference__update(repo, git_object_id(commit), GIT_HEAD_FILE) < 0)
+ if (git_repository_head(&head, repo) < 0)
+ goto cleanup;
+
+ if (git_reference_set_oid(head, git_object_id(commit)) < 0)
goto cleanup;
if (reset_type == GIT_RESET_SOFT) {
@@ -96,6 +100,7 @@ int git_reset(
error = 0;
cleanup:
+ git_reference_free(head);
git_object_free(commit);
git_index_free(index);
git_tree_free(tree);