diff options
| author | Vicent Martà <vicent@github.com> | 2012-07-11 05:29:51 -0700 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2012-07-11 05:29:51 -0700 |
| commit | a13a30ac302ede33d8bc4b6b0c283a57f6e8cc2e (patch) | |
| tree | e6cfedbe35b0b397ec89ffbdd30ea3903241e1d3 /tests-clar/refs/reflog.c | |
| parent | 6b9a49cd5fd6addc5b9ce3281ea33a50934f5a94 (diff) | |
| parent | 3e82d6c6f0783a5c74b79d7a849e9ca319f171b5 (diff) | |
| download | libgit2-a13a30ac302ede33d8bc4b6b0c283a57f6e8cc2e.tar.gz | |
Merge pull request #801 from nulltoken/fix/ref-renaming
refs and revparse love <3
Diffstat (limited to 'tests-clar/refs/reflog.c')
| -rw-r--r-- | tests-clar/refs/reflog.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/tests-clar/refs/reflog.c b/tests-clar/refs/reflog.c index 1bc51b2b8..05f3786bb 100644 --- a/tests-clar/refs/reflog.c +++ b/tests-clar/refs/reflog.c @@ -26,7 +26,7 @@ static void assert_signature(git_signature *expected, git_signature *actual) // Fixture setup and teardown void test_refs_reflog__initialize(void) { - g_repo = cl_git_sandbox_init("testrepo"); + g_repo = cl_git_sandbox_init("testrepo.git"); } void test_refs_reflog__cleanup(void) @@ -61,7 +61,7 @@ void test_refs_reflog__write_then_read(void) cl_git_pass(git_reflog_write(ref, &oid, committer, commit_msg)); /* Reopen a new instance of the repository */ - cl_git_pass(git_repository_open(&repo2, "testrepo")); + cl_git_pass(git_repository_open(&repo2, "testrepo.git")); /* Lookup the preivously created branch */ cl_git_pass(git_reference_lookup(&lookedup_ref, repo2, new_ref)); @@ -121,3 +121,44 @@ void test_refs_reflog__dont_write_bad(void) git_reference_free(ref); } + +void test_refs_reflog__renaming_the_reference_moves_the_reflog(void) +{ + git_reference *master; + git_buf master_log_path = GIT_BUF_INIT, moved_log_path = GIT_BUF_INIT; + + git_buf_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR); + git_buf_puts(&moved_log_path, git_buf_cstr(&master_log_path)); + git_buf_joinpath(&master_log_path, git_buf_cstr(&master_log_path), "refs/heads/master"); + git_buf_joinpath(&moved_log_path, git_buf_cstr(&moved_log_path), "refs/moved"); + + cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&master_log_path))); + cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&moved_log_path))); + + cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master")); + cl_git_pass(git_reference_rename(master, "refs/moved", 0)); + + cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&master_log_path))); + cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&moved_log_path))); + + git_reference_free(master); + git_buf_free(&moved_log_path); + git_buf_free(&master_log_path); +} +static void assert_has_reflog(bool expected_result, const char *name) +{ + git_reference *ref; + + cl_git_pass(git_reference_lookup(&ref, g_repo, name)); + + cl_assert_equal_i(expected_result, git_reference_has_log(ref)); + + git_reference_free(ref); +} + +void test_refs_reflog__reference_has_reflog(void) +{ + assert_has_reflog(true, "HEAD"); + assert_has_reflog(true, "refs/heads/master"); + assert_has_reflog(false, "refs/heads/subtrees"); +} |
