diff options
| author | nulltoken <emeric.fermas@gmail.com> | 2012-07-18 20:12:45 +0200 |
|---|---|---|
| committer | nulltoken <emeric.fermas@gmail.com> | 2012-07-25 07:53:30 +0200 |
| commit | bd72425d16fce9771af7727029f7d8ea8c2e98d2 (patch) | |
| tree | f4a9367ebf29fb7552faad8136dd68f1743212c0 /tests-clar/refs | |
| parent | d284b3de631edeaa651bf3ee2c5963cb970016c4 (diff) | |
| download | libgit2-bd72425d16fce9771af7727029f7d8ea8c2e98d2.tar.gz | |
reflog: introduce git_reflog_write()
Diffstat (limited to 'tests-clar/refs')
| -rw-r--r-- | tests-clar/refs/reflog/drop.c | 19 | ||||
| -rw-r--r-- | tests-clar/refs/reflog/reflog.c | 8 |
2 files changed, 23 insertions, 4 deletions
diff --git a/tests-clar/refs/reflog/drop.c b/tests-clar/refs/reflog/drop.c index be404947e..3aa99fe09 100644 --- a/tests-clar/refs/reflog/drop.c +++ b/tests-clar/refs/reflog/drop.c @@ -109,3 +109,22 @@ void test_refs_reflog_drop__can_drop_all_the_entries(void) cl_assert_equal_i(0, git_reflog_entrycount(g_reflog)); } + +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_entry_drop(g_reflog, entrycount - 1, 1)); + cl_assert_equal_i(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); + + cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog)); +} diff --git a/tests-clar/refs/reflog/reflog.c b/tests-clar/refs/reflog/reflog.c index 08b7754be..ac61f1343 100644 --- a/tests-clar/refs/reflog/reflog.c +++ b/tests-clar/refs/reflog/reflog.c @@ -7,7 +7,7 @@ static const char *new_ref = "refs/heads/test-reflog"; static const char *current_master_tip = "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"; -static const char *commit_msg = "commit: bla bla"; +#define commit_msg "commit: bla bla" static git_repository *g_repo; @@ -57,13 +57,13 @@ void test_refs_reflog_reflog__append_then_read(void) cl_git_pass(git_reflog_append(ref, NULL, committer, NULL)); cl_git_fail(git_reflog_append(ref, NULL, committer, "no ancestor NULL for an existing reflog")); - cl_git_fail(git_reflog_append(ref, NULL, committer, "no\nnewline")); - cl_git_pass(git_reflog_append(ref, &oid, committer, commit_msg)); + cl_git_fail(git_reflog_append(ref, NULL, committer, "no inner\nnewline")); + cl_git_pass(git_reflog_append(ref, &oid, committer, commit_msg "\n")); /* Reopen a new instance of the repository */ cl_git_pass(git_repository_open(&repo2, "testrepo.git")); - /* Lookup the preivously created branch */ + /* Lookup the previously created branch */ cl_git_pass(git_reference_lookup(&lookedup_ref, repo2, new_ref)); /* Read and parse the reflog for this branch */ |
