summaryrefslogtreecommitdiff
path: root/tests/libgit2/core
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@vercel.com>2023-02-25 22:24:10 +0000
committerEdward Thomson <ethomson@vercel.com>2023-02-25 22:25:12 +0000
commite25f9a9bb85e062aeff3d0713e35dd1ad31962d3 (patch)
treefeb0b856b1552da39bd130e2b9960983ac182488 /tests/libgit2/core
parent8a871d13b7f4e186b8ad943ae5a7fcf30be52e67 (diff)
downloadlibgit2-e25f9a9bb85e062aeff3d0713e35dd1ad31962d3.tar.gz
repo: don't allow repeated extensions
If a user attempts to add a custom extension that the system already supports, or that is already in their list of custom extensions, de-dup it.
Diffstat (limited to 'tests/libgit2/core')
-rw-r--r--tests/libgit2/core/opts.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/libgit2/core/opts.c b/tests/libgit2/core/opts.c
index 486ff58c6..1aa095adf 100644
--- a/tests/libgit2/core/opts.c
+++ b/tests/libgit2/core/opts.c
@@ -50,9 +50,9 @@ void test_core_opts__extensions_add(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out));
cl_assert_equal_sz(out.count, 3);
- cl_assert_equal_s("noop", out.strings[0]);
- cl_assert_equal_s("objectformat", out.strings[1]);
- cl_assert_equal_s("foo", out.strings[2]);
+ cl_assert_equal_s("foo", out.strings[0]);
+ cl_assert_equal_s("noop", out.strings[1]);
+ cl_assert_equal_s("objectformat", out.strings[2]);
git_strarray_dispose(&out);
}
@@ -66,9 +66,26 @@ void test_core_opts__extensions_remove(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out));
cl_assert_equal_sz(out.count, 3);
- cl_assert_equal_s("objectformat", out.strings[0]);
- cl_assert_equal_s("bar", out.strings[1]);
- cl_assert_equal_s("baz", out.strings[2]);
+ cl_assert_equal_s("bar", out.strings[0]);
+ cl_assert_equal_s("baz", out.strings[1]);
+ cl_assert_equal_s("objectformat", out.strings[2]);
+
+ git_strarray_dispose(&out);
+}
+
+void test_core_opts__extensions_uniq(void)
+{
+ const char *in[] = { "foo", "noop", "bar", "bar", "foo", "objectformat" };
+ git_strarray out = { 0 };
+
+ cl_git_pass(git_libgit2_opts(GIT_OPT_SET_EXTENSIONS, in, ARRAY_SIZE(in)));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_GET_EXTENSIONS, &out));
+
+ cl_assert_equal_sz(out.count, 4);
+ cl_assert_equal_s("bar", out.strings[0]);
+ cl_assert_equal_s("foo", out.strings[1]);
+ cl_assert_equal_s("noop", out.strings[2]);
+ cl_assert_equal_s("objectformat", out.strings[3]);
git_strarray_dispose(&out);
}