Commit 03bdb2addd02948e0e42b509e5c26c6eb5e7e1de

Edward Thomson 2012-10-23T16:32:01

GIT_EUNMERGED

diff --git a/include/git2/errors.h b/include/git2/errors.h
index 38b7fe0..fb56dcc 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 aff5b9f..66338e6 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 6796c80..fa20645 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)));
 }