summaryrefslogtreecommitdiff
path: root/src/reset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reset.c')
-rw-r--r--src/reset.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/reset.c b/src/reset.c
index 0ffa51b66..f8a1a1dc8 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -145,19 +145,19 @@ static int reset(
if ((error = git_buf_printf(&log_message, "reset: moving to %s", to)) < 0)
return error;
- /* move HEAD to the new target */
- if ((error = git_reference__update_terminal(repo, GIT_HEAD_FILE,
- git_object_id(commit), NULL, git_buf_cstr(&log_message))) < 0)
- goto cleanup;
-
if (reset_type == GIT_RESET_HARD) {
- /* overwrite working directory with HEAD */
+ /* overwrite working directory with the new tree */
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
if ((error = git_checkout_tree(repo, (git_object *)tree, &opts)) < 0)
goto cleanup;
}
+ /* move HEAD to the new target */
+ if ((error = git_reference__update_terminal(repo, GIT_HEAD_FILE,
+ git_object_id(commit), NULL, git_buf_cstr(&log_message))) < 0)
+ goto cleanup;
+
if (reset_type > GIT_RESET_SOFT) {
/* reset index to the target content */