reset: make reset rely on git_repository_head()

This commit is contained in:
nulltoken 2012-09-22 12:47:17 +02:00
parent b52b6571af
commit a147408f94

View File

@ -29,6 +29,7 @@ int git_reset(
git_tree *tree = NULL; git_tree *tree = NULL;
int error = -1; int error = -1;
git_checkout_opts opts; git_checkout_opts opts;
git_reference *head = NULL;
assert(repo && target); assert(repo && target);
assert(reset_type == GIT_RESET_SOFT assert(reset_type == GIT_RESET_SOFT
@ -49,7 +50,10 @@ int git_reset(
//TODO: Check for unmerged entries //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; goto cleanup;
if (reset_type == GIT_RESET_SOFT) { if (reset_type == GIT_RESET_SOFT) {
@ -96,6 +100,7 @@ int git_reset(
error = 0; error = 0;
cleanup: cleanup:
git_reference_free(head);
git_object_free(commit); git_object_free(commit);
git_index_free(index); git_index_free(index);
git_tree_free(tree); git_tree_free(tree);