summaryrefslogtreecommitdiff
path: root/tests-clar/reset/soft.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests-clar/reset/soft.c')
-rw-r--r--tests-clar/reset/soft.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/tests-clar/reset/soft.c b/tests-clar/reset/soft.c
index 3200c1591..1872baf3b 100644
--- a/tests-clar/reset/soft.c
+++ b/tests-clar/reset/soft.c
@@ -1,5 +1,6 @@
#include "clar_libgit2.h"
#include "reset_helpers.h"
+#include "repo/repo_helpers.h"
static git_repository *repo;
static git_object *target;
@@ -39,20 +40,9 @@ void test_reset_soft__can_reset_the_non_detached_Head_to_the_specified_commit(vo
assert_reset_soft(false);
}
-static void detach_head(void)
-{
- git_reference *head;
- git_oid oid;
-
- cl_git_pass(git_reference_name_to_oid(&oid, repo, "HEAD"));
-
- cl_git_pass(git_reference_create_oid(&head, repo, "HEAD", &oid, true));
- git_reference_free(head);
-}
-
void test_reset_soft__can_reset_the_detached_Head_to_the_specified_commit(void)
{
- detach_head();
+ git_repository_detach_head(repo);
assert_reset_soft(true);
}
@@ -100,3 +90,23 @@ void test_reset_soft__cannot_reset_to_a_tag_not_pointing_at_a_commit(void)
retrieve_target_from_oid(&target, repo, "521d87c1ec3aef9824daf6d96cc0ae3710766d91");
cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT));
}
+
+void test_reset_soft__resetting_against_an_orphaned_head_repo_makes_the_head_no_longer_orphaned(void)
+{
+ git_reference *head;
+
+ retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
+
+ make_head_orphaned(repo, NON_EXISTING_HEAD);
+
+ cl_assert_equal_i(true, git_repository_head_orphan(repo));
+
+ cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+
+ cl_assert_equal_i(false, git_repository_head_orphan(repo));
+
+ cl_git_pass(git_reference_lookup(&head, repo, NON_EXISTING_HEAD));
+ cl_assert_equal_i(0, git_oid_streq(git_reference_oid(head), KNOWN_COMMIT_IN_BARE_REPO));
+
+ git_reference_free(head);
+}