diff options
| author | nulltoken <emeric.fermas@gmail.com> | 2012-10-20 12:09:02 +0200 |
|---|---|---|
| committer | nulltoken <emeric.fermas@gmail.com> | 2012-10-22 19:46:00 +0200 |
| commit | c436ed26e08fde69579d5d0ac31e775cfbd06290 (patch) | |
| tree | b107ddb3e8e21ec1ba35adce60bbe246277f24e4 /tests-clar | |
| parent | cd1ef82253b5f4242ed9aed5e9abf7bceb33ec04 (diff) | |
| download | libgit2-c436ed26e08fde69579d5d0ac31e775cfbd06290.tar.gz | |
reset: make git_reset() cope with an orphaned HEAD
Diffstat (limited to 'tests-clar')
| -rw-r--r-- | tests-clar/reset/soft.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests-clar/reset/soft.c b/tests-clar/reset/soft.c index 3c678ad73..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; @@ -89,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); +} |
