summaryrefslogtreecommitdiff
path: root/tests/index/version.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-08-17 09:24:44 -0500
committerGitHub <noreply@github.com>2016-08-17 09:24:44 -0500
commitc1b370e9313a13df350974e2237997cc651a5d67 (patch)
tree192fffba5ba3bb5982cb675955d647cbd170b54c /tests/index/version.c
parent635a922274046ee077235b9764d0360e33d735ab (diff)
parent5625d86b994fd81f1b0d887890e8168d7b5f46cc (diff)
downloadlibgit2-c1b370e9313a13df350974e2237997cc651a5d67.tar.gz
Merge pull request #3837 from novalis/dturner/indexv4
Support index v4
Diffstat (limited to 'tests/index/version.c')
-rw-r--r--tests/index/version.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/index/version.c b/tests/index/version.c
new file mode 100644
index 000000000..3fd240d3c
--- /dev/null
+++ b/tests/index/version.c
@@ -0,0 +1,41 @@
+#include "clar_libgit2.h"
+#include "index.h"
+
+static git_repository *g_repo = NULL;
+
+void test_index_version__can_write_v4(void)
+{
+ git_index *index;
+ const git_index_entry *entry;
+
+ g_repo = cl_git_sandbox_init("filemodes");
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ cl_assert(index->on_disk);
+ cl_assert(git_index_version(index) == 2);
+
+ cl_assert(git_index_entrycount(index) == 6);
+
+ cl_git_pass(git_index_set_version(index, 4));
+
+ cl_git_pass(git_index_write(index));
+ git_index_free(index);
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_assert(git_index_version(index) == 4);
+
+ entry = git_index_get_bypath(index, "exec_off", 0);
+ cl_assert(entry);
+ entry = git_index_get_bypath(index, "exec_off2on_staged", 0);
+ cl_assert(entry);
+ entry = git_index_get_bypath(index, "exec_on", 0);
+ cl_assert(entry);
+
+ git_index_free(index);
+}
+
+void test_index_version__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+ g_repo = NULL;
+}