diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2013-08-19 13:01:49 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-10-02 06:53:24 +0200 |
| commit | b976f3c2c228413d124be8fea3280a44bd5e3136 (patch) | |
| tree | 32e6712711c61a5d27bbed347901afc242bdc8dd /tests-clar | |
| parent | 71e33d2649f990086237a6cd0fdb7f7d6f742b51 (diff) | |
| download | libgit2-b976f3c2c228413d124be8fea3280a44bd5e3136.tar.gz | |
reflog: move the reflog implementation into refdb_fs
References and their logs are logically coupled, let's make it so in
the code by moving the fs-based reflog implementation to live next to
the fs-based refs one.
As part of the change, make the function take names rather than
references, as only the names are relevant when looking up and
handling reflogs.
Diffstat (limited to 'tests-clar')
| -rw-r--r-- | tests-clar/refs/reflog/drop.c | 13 | ||||
| -rw-r--r-- | tests-clar/refs/reflog/reflog.c | 23 | ||||
| -rw-r--r-- | tests-clar/stash/drop.c | 4 |
3 files changed, 11 insertions, 29 deletions
diff --git a/tests-clar/refs/reflog/drop.c b/tests-clar/refs/reflog/drop.c index 21cc847bf..916bd9933 100644 --- a/tests-clar/refs/reflog/drop.c +++ b/tests-clar/refs/reflog/drop.c @@ -8,15 +8,10 @@ static size_t entrycount; void test_refs_reflog_drop__initialize(void) { - git_reference *ref; - g_repo = cl_git_sandbox_init("testrepo.git"); - cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD")); - git_reflog_read(&g_reflog, ref); + git_reflog_read(&g_reflog, g_repo, "HEAD"); entrycount = git_reflog_entrycount(g_reflog); - - git_reference_free(ref); } void test_refs_reflog_drop__cleanup(void) @@ -106,19 +101,15 @@ void test_refs_reflog_drop__can_drop_all_the_entries(void) void test_refs_reflog_drop__can_persist_deletion_on_disk(void) { - git_reference *ref; - cl_assert(entrycount > 2); - cl_git_pass(git_reference_lookup(&ref, g_repo, g_reflog->ref_name)); cl_git_pass(git_reflog_drop(g_reflog, 0, 1)); cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog)); cl_git_pass(git_reflog_write(g_reflog)); git_reflog_free(g_reflog); - git_reflog_read(&g_reflog, ref); - git_reference_free(ref); + git_reflog_read(&g_reflog, g_repo, "HEAD"); cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog)); } diff --git a/tests-clar/refs/reflog/reflog.c b/tests-clar/refs/reflog/reflog.c index 095cabf04..327c85799 100644 --- a/tests-clar/refs/reflog/reflog.c +++ b/tests-clar/refs/reflog/reflog.c @@ -50,7 +50,7 @@ void test_refs_reflog_reflog__append_then_read(void) cl_git_pass(git_signature_now(&committer, "foo", "foo@bar")); - cl_git_pass(git_reflog_read(&reflog, ref)); + cl_git_pass(git_reflog_read(&reflog, g_repo, new_ref)); cl_git_fail(git_reflog_append(reflog, &oid, committer, "no inner\nnewline")); cl_git_pass(git_reflog_append(reflog, &oid, committer, NULL)); @@ -65,7 +65,7 @@ void test_refs_reflog_reflog__append_then_read(void) cl_git_pass(git_reference_lookup(&lookedup_ref, repo2, new_ref)); /* Read and parse the reflog for this branch */ - cl_git_pass(git_reflog_read(&reflog, lookedup_ref)); + cl_git_pass(git_reflog_read(&reflog, repo2, new_ref)); cl_assert_equal_i(2, (int)git_reflog_entrycount(reflog)); entry = git_reflog_entry_byindex(reflog, 1); @@ -133,21 +133,18 @@ void test_refs_reflog_reflog__reference_has_reflog(void) void test_refs_reflog_reflog__reading_the_reflog_from_a_reference_with_no_log_returns_an_empty_one(void) { - git_reference *subtrees; git_reflog *reflog; + const char *refname = "refs/heads/subtrees"; git_buf subtrees_log_path = GIT_BUF_INIT; - cl_git_pass(git_reference_lookup(&subtrees, g_repo, "refs/heads/subtrees")); - - git_buf_join_n(&subtrees_log_path, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, git_reference_name(subtrees)); + git_buf_join_n(&subtrees_log_path, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname); cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&subtrees_log_path))); - cl_git_pass(git_reflog_read(&reflog, subtrees)); + cl_git_pass(git_reflog_read(&reflog, g_repo, refname)); cl_assert_equal_i(0, (int)git_reflog_entrycount(reflog)); git_reflog_free(reflog); - git_reference_free(subtrees); git_buf_free(&subtrees_log_path); } @@ -158,7 +155,7 @@ void test_refs_reflog_reflog__cannot_write_a_moved_reflog(void) git_reflog *reflog; cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master")); - cl_git_pass(git_reflog_read(&reflog, master)); + cl_git_pass(git_reflog_read(&reflog, g_repo, "refs/heads/master")); cl_git_pass(git_reflog_write(reflog)); @@ -175,12 +172,6 @@ void test_refs_reflog_reflog__cannot_write_a_moved_reflog(void) void test_refs_reflog_reflog__renaming_with_an_invalid_name_returns_EINVALIDSPEC(void) { - git_reference *master; - - cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master")); - cl_assert_equal_i(GIT_EINVALIDSPEC, - git_reflog_rename(master, "refs/heads/Inv@{id")); - - git_reference_free(master); + git_reflog_rename(g_repo, "refs/heads/master", "refs/heads/Inv@{id")); } diff --git a/tests-clar/stash/drop.c b/tests-clar/stash/drop.c index 59413f01e..63ff0377c 100644 --- a/tests-clar/stash/drop.c +++ b/tests-clar/stash/drop.c @@ -102,7 +102,7 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void) cl_git_pass(git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)); - cl_git_pass(git_reflog_read(&reflog, stash)); + cl_git_pass(git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)); entry = git_reflog_entry_byindex(reflog, 1); git_oid_cpy(&oid, git_reflog_entry_id_old(entry)); @@ -112,7 +112,7 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void) cl_git_pass(git_stash_drop(repo, 1)); - cl_git_pass(git_reflog_read(&reflog, stash)); + cl_git_pass(git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)); entry = git_reflog_entry_byindex(reflog, 0); cl_assert_equal_i(0, git_oid_cmp(&oid, git_reflog_entry_id_old(entry))); |
