summaryrefslogtreecommitdiff
path: root/tests-clar
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-11-17 18:29:51 -0800
committernulltoken <emeric.fermas@gmail.com>2012-11-17 18:30:35 -0800
commitb15df1d937128bb7051ab35084195ff1980a7869 (patch)
treeccac67d86df9f6f8f2276d2b4f4b43555e99b20e /tests-clar
parent1a764476d27ac1861d1433b02bc7fbff733d8942 (diff)
downloadlibgit2-b15df1d937128bb7051ab35084195ff1980a7869.tar.gz
reflog: make entry_byindex() and drop() git compliant
Passing 0 as the index now retrieves the most recent entry instead of the oldest one.
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/refs/reflog/drop.c22
-rw-r--r--tests-clar/refs/reflog/reflog.c4
-rw-r--r--tests-clar/stash/drop.c2
3 files changed, 15 insertions, 13 deletions
diff --git a/tests-clar/refs/reflog/drop.c b/tests-clar/refs/reflog/drop.c
index 4be857b42..512e8ba02 100644
--- a/tests-clar/refs/reflog/drop.c
+++ b/tests-clar/refs/reflog/drop.c
@@ -49,14 +49,16 @@ void test_refs_reflog_drop__can_drop_an_entry_and_rewrite_the_log_history(void)
cl_assert(entrycount > 4);
- before_current = git_reflog_entry_byindex(g_reflog, 2);
+ before_current = git_reflog_entry_byindex(g_reflog, 1);
+
git_oid_cpy(&before_current_old_oid, &before_current->oid_old);
git_oid_cpy(&before_current_cur_oid, &before_current->oid_cur);
- cl_git_pass(git_reflog_drop(g_reflog, 2, 1));
+ cl_git_pass(git_reflog_drop(g_reflog, 1, 1));
+
cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
- after_current = git_reflog_entry_byindex(g_reflog, 2);
+ after_current = git_reflog_entry_byindex(g_reflog, 0);
cl_assert_equal_i(0, git_oid_cmp(&before_current_old_oid, &after_current->oid_old));
cl_assert(0 != git_oid_cmp(&before_current_cur_oid, &after_current->oid_cur));
@@ -68,10 +70,10 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry(void)
cl_assert(entrycount > 2);
- cl_git_pass(git_reflog_drop(g_reflog, 0, 0));
+ cl_git_pass(git_reflog_drop(g_reflog, entrycount - 1, 0));
cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
- entry = git_reflog_entry_byindex(g_reflog, 0);
+ entry = git_reflog_entry_byindex(g_reflog, entrycount - 2);
cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) != 0);
}
@@ -81,10 +83,10 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry_and_rewrite_the_log_histor
cl_assert(entrycount > 2);
- cl_git_pass(git_reflog_drop(g_reflog, 0, 1));
+ cl_git_pass(git_reflog_drop(g_reflog, entrycount - 1, 1));
cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
- entry = git_reflog_entry_byindex(g_reflog, 0);
+ entry = git_reflog_entry_byindex(g_reflog, entrycount - 2);
cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) == 0);
}
@@ -93,8 +95,8 @@ void test_refs_reflog_drop__can_drop_all_the_entries(void)
cl_assert(--entrycount > 0);
do {
- cl_git_pass(git_reflog_drop(g_reflog, --entrycount, 1));
- } while (entrycount > 0);
+ cl_git_pass(git_reflog_drop(g_reflog, 0, 1));
+ } while (--entrycount > 0);
cl_git_pass(git_reflog_drop(g_reflog, 0, 1));
@@ -108,7 +110,7 @@ void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
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, entrycount - 1, 1));
+ cl_git_pass(git_reflog_drop(g_reflog, 0, 1));
cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
cl_git_pass(git_reflog_write(g_reflog));
diff --git a/tests-clar/refs/reflog/reflog.c b/tests-clar/refs/reflog/reflog.c
index 20f08f523..09b935692 100644
--- a/tests-clar/refs/reflog/reflog.c
+++ b/tests-clar/refs/reflog/reflog.c
@@ -68,13 +68,13 @@ void test_refs_reflog_reflog__append_then_read(void)
cl_git_pass(git_reflog_read(&reflog, lookedup_ref));
cl_assert_equal_i(2, git_reflog_entrycount(reflog));
- entry = git_reflog_entry_byindex(reflog, 0);
+ entry = git_reflog_entry_byindex(reflog, 1);
assert_signature(committer, entry->committer);
cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) == 0);
cl_assert(git_oid_cmp(&oid, &entry->oid_cur) == 0);
cl_assert(entry->msg == NULL);
- entry = git_reflog_entry_byindex(reflog, 1);
+ entry = git_reflog_entry_byindex(reflog, 0);
assert_signature(committer, entry->committer);
cl_assert(git_oid_cmp(&oid, &entry->oid_old) == 0);
cl_assert(git_oid_cmp(&oid, &entry->oid_cur) == 0);
diff --git a/tests-clar/stash/drop.c b/tests-clar/stash/drop.c
index 39139ccae..b4f73b995 100644
--- a/tests-clar/stash/drop.c
+++ b/tests-clar/stash/drop.c
@@ -99,7 +99,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));
- entry = git_reflog_entry_byindex(reflog, 1);
+ entry = git_reflog_entry_byindex(reflog, 0);
cl_assert_equal_i(0, git_oid_cmp(&oid, git_reflog_entry_oidold(entry)));
cl_assert_equal_i(count - 1, git_reflog_entrycount(reflog));