diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-08-19 21:24:51 +0200 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-09-17 10:48:28 +0200 |
commit | ee8bb8ba649118c4abb09cb02bd3c02e60b98e06 (patch) | |
tree | bcbcdb7e25aac03a883de3f15de977192602e4da /src/reset.c | |
parent | e93af304112735f02bfeb0833b58ed8230de2371 (diff) | |
download | libgit2-ee8bb8ba649118c4abb09cb02bd3c02e60b98e06.tar.gz |
reset: add support for GIT_RESET_HARD mode
Diffstat (limited to 'src/reset.c')
-rw-r--r-- | src/reset.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/reset.c b/src/reset.c index 5aaf94840..efe3b6be9 100644 --- a/src/reset.c +++ b/src/reset.c @@ -9,6 +9,7 @@ #include "commit.h" #include "tag.h" #include "git2/reset.h" +#include "git2/checkout.h" #define ERROR_MSG "Cannot perform reset" @@ -29,7 +30,9 @@ int git_reset( int error = -1; assert(repo && target); - assert(reset_type == GIT_RESET_SOFT || reset_type == GIT_RESET_MIXED); + assert(reset_type == GIT_RESET_SOFT + || reset_type == GIT_RESET_MIXED + || reset_type == GIT_RESET_HARD); if (git_object_owner(target) != repo) return reset_error_invalid("The given target does not belong to this repository."); @@ -73,6 +76,16 @@ int git_reset( goto cleanup; } + if (reset_type == GIT_RESET_MIXED) { + error = 0; + goto cleanup; + } + + if (git_checkout_index(repo, NULL, NULL, NULL) < 0) { + giterr_set(GITERR_INDEX, "%s - Failed to checkout the index.", ERROR_MSG); + goto cleanup; + } + error = 0; cleanup: |