summaryrefslogtreecommitdiff
path: root/tests/libgit2/refs/cmp.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-07-07 21:30:28 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2022-07-07 21:30:28 -0400
commit2a4d100ae862bc964c36d41ff69a5f0b17c5515d (patch)
tree5753c498acf09dc0282a6e44f564c52b0046d500 /tests/libgit2/refs/cmp.c
parent92ffdd2cd243a49fafb317ea3a819dbe8a6dd3c9 (diff)
downloadlibgit2-ethomson/reference_cmp.tar.gz
refs: make `git_reference_cmp` consider the nameethomson/reference_cmp
`git_reference_cmp` only considers the target of a reference, and ignores the name. Meaning that a reference `foo` and reference `bar` pointing to the same commit will compare equal. Correct this, comparing the name _and_ target of a reference.
Diffstat (limited to 'tests/libgit2/refs/cmp.c')
-rw-r--r--tests/libgit2/refs/cmp.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/libgit2/refs/cmp.c b/tests/libgit2/refs/cmp.c
new file mode 100644
index 000000000..78d90b04a
--- /dev/null
+++ b/tests/libgit2/refs/cmp.c
@@ -0,0 +1,27 @@
+#include "clar_libgit2.h"
+#include "refs.h"
+
+static git_repository *g_repo;
+
+void test_refs_cmp__initialize(void)
+{
+ g_repo = cl_git_sandbox_init("testrepo2");
+}
+
+void test_refs_cmp__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_refs_cmp__symbolic(void)
+{
+ git_reference *one, *two;
+
+ cl_git_pass(git_reference_lookup(&one, g_repo, "refs/heads/symbolic-one"));
+ cl_git_pass(git_reference_lookup(&two, g_repo, "refs/heads/symbolic-two"));
+
+ cl_assert(git_reference_cmp(one, two) != 0);
+
+ git_reference_free(one);
+ git_reference_free(two);
+}