From 03bdb2addd02948e0e42b509e5c26c6eb5e7e1de Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Tue, 23 Oct 2012 16:32:01 -0500 Subject: [PATCH] GIT_EUNMERGED --- include/git2/errors.h | 1 + src/reset.c | 1 + tests-clar/reset/soft.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/git2/errors.h b/include/git2/errors.h index 38b7fe0ae..fb56dcc6b 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -28,6 +28,7 @@ enum { GIT_EUSER = -7, GIT_EBAREREPO = -8, GIT_EORPHANEDHEAD = -9, + GIT_EUNMERGED = -10, GIT_PASSTHROUGH = -30, GIT_ITEROVER = -31, diff --git a/src/reset.c b/src/reset.c index aff5b9f88..66338e655 100644 --- a/src/reset.c +++ b/src/reset.c @@ -92,6 +92,7 @@ int git_reset( if (reset_type == GIT_RESET_SOFT && (git_repository_state(repo) == GIT_REPOSITORY_STATE_MERGE)) { giterr_set(GITERR_OBJECT, "%s (soft) while in the middle of a merge.", ERROR_MSG); + error = GIT_EUNMERGED; goto cleanup; } diff --git a/tests-clar/reset/soft.c b/tests-clar/reset/soft.c index 6796c80bc..fa206455d 100644 --- a/tests-clar/reset/soft.c +++ b/tests-clar/reset/soft.c @@ -120,6 +120,8 @@ void test_reset_soft__fails_when_merging(void) cl_git_pass(git_buf_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD")); cl_git_mkfile(git_buf_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n"); - cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT)); + retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO); + + cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT)); cl_git_pass(p_unlink(git_buf_cstr(&merge_head_path))); }