diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-07 21:30:28 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-07-07 21:30:28 -0400 |
commit | 2a4d100ae862bc964c36d41ff69a5f0b17c5515d (patch) | |
tree | 5753c498acf09dc0282a6e44f564c52b0046d500 /src | |
parent | 92ffdd2cd243a49fafb317ea3a819dbe8a6dd3c9 (diff) | |
download | libgit2-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 'src')
-rw-r--r-- | src/libgit2/refs.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libgit2/refs.c b/src/libgit2/refs.c index 5c875b95b..72100b6ed 100644 --- a/src/libgit2/refs.c +++ b/src/libgit2/refs.c @@ -1054,10 +1054,14 @@ int git_reference_cmp( const git_reference *ref2) { git_reference_t type1, type2; + int ret; GIT_ASSERT_ARG(ref1); GIT_ASSERT_ARG(ref2); + if ((ret = strcmp(ref1->name, ref2->name)) != 0) + return ret; + type1 = git_reference_type(ref1); type2 = git_reference_type(ref2); |