From 0bf7e0433dc0a5a71b4ed6575b84c552825e82fd Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Thu, 24 Jan 2019 12:12:04 +0100 Subject: index: preserve extension parsing errors Previously, we would clobber any extension-specific error message with an "extension is truncated" message. This makes `read_extension` correctly preserve those errors, takes responsibility for truncation errors, and adds a new message with the actual extension signature for unsupported mandatory extensions. --- tests/index/splitindex.c | 21 +++++++++++++++++++++ tests/resources/splitindex/.gitted/HEAD | 1 + tests/resources/splitindex/.gitted/config | 8 ++++++++ tests/resources/splitindex/.gitted/index | Bin 0 -> 100 bytes tests/resources/splitindex/.gitted/info/exclude | 6 ++++++ .../resources/splitindex/.gitted/objects/.gitkeep | 0 tests/resources/splitindex/.gitted/refs/.gitkeep | 0 ...dindex.39d890139ee5356c7ef572216cebcd27aa41f9df | Bin 0 -> 32 bytes 8 files changed, 36 insertions(+) create mode 100644 tests/index/splitindex.c create mode 100644 tests/resources/splitindex/.gitted/HEAD create mode 100644 tests/resources/splitindex/.gitted/config create mode 100644 tests/resources/splitindex/.gitted/index create mode 100644 tests/resources/splitindex/.gitted/info/exclude create mode 100644 tests/resources/splitindex/.gitted/objects/.gitkeep create mode 100644 tests/resources/splitindex/.gitted/refs/.gitkeep create mode 100644 tests/resources/splitindex/.gitted/sharedindex.39d890139ee5356c7ef572216cebcd27aa41f9df (limited to 'tests') diff --git a/tests/index/splitindex.c b/tests/index/splitindex.c new file mode 100644 index 000000000..d32ed1022 --- /dev/null +++ b/tests/index/splitindex.c @@ -0,0 +1,21 @@ +#include "clar_libgit2.h" +#include "index.h" + +static git_repository *g_repo; + +void test_index_splitindex__initialize(void) +{ + g_repo = cl_git_sandbox_init("splitindex"); +} + +void test_index_splitindex__cleanup(void) +{ + cl_git_sandbox_cleanup(); +} + +void test_index_splitindex__fail_on_open(void) +{ + git_index *idx; + cl_git_fail_with(-1, git_repository_index(&idx, g_repo)); + cl_assert_equal_s(git_error_last()->message, "unsupported mandatory extension: 'link'"); +} diff --git a/tests/resources/splitindex/.gitted/HEAD b/tests/resources/splitindex/.gitted/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests/resources/splitindex/.gitted/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests/resources/splitindex/.gitted/config b/tests/resources/splitindex/.gitted/config new file mode 100644 index 000000000..e9d0b6d3b --- /dev/null +++ b/tests/resources/splitindex/.gitted/config @@ -0,0 +1,8 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true + splitIndex = true diff --git a/tests/resources/splitindex/.gitted/index b/tests/resources/splitindex/.gitted/index new file mode 100644 index 000000000..ff3448847 Binary files /dev/null and b/tests/resources/splitindex/.gitted/index differ diff --git a/tests/resources/splitindex/.gitted/info/exclude b/tests/resources/splitindex/.gitted/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/tests/resources/splitindex/.gitted/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests/resources/splitindex/.gitted/objects/.gitkeep b/tests/resources/splitindex/.gitted/objects/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/tests/resources/splitindex/.gitted/refs/.gitkeep b/tests/resources/splitindex/.gitted/refs/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/tests/resources/splitindex/.gitted/sharedindex.39d890139ee5356c7ef572216cebcd27aa41f9df b/tests/resources/splitindex/.gitted/sharedindex.39d890139ee5356c7ef572216cebcd27aa41f9df new file mode 100644 index 000000000..3330d716f Binary files /dev/null and b/tests/resources/splitindex/.gitted/sharedindex.39d890139ee5356c7ef572216cebcd27aa41f9df differ -- cgit v1.2.1