Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
6d8c7cab
Commit
6d8c7cab
authored
Jan 21, 2022
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oid: introduce `git_oid_raw_ncmp`
parent
526e8869
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
19 deletions
+24
-19
src/libgit2/oid.c
+1
-19
src/libgit2/oid.h
+23
-0
No files found.
src/libgit2/oid.c
View file @
6d8c7cab
...
...
@@ -203,25 +203,7 @@ int git_oid_equal(const git_oid *a, const git_oid *b)
int
git_oid_ncmp
(
const
git_oid
*
oid_a
,
const
git_oid
*
oid_b
,
size_t
len
)
{
const
unsigned
char
*
a
=
oid_a
->
id
;
const
unsigned
char
*
b
=
oid_b
->
id
;
if
(
len
>
GIT_OID_HEXSZ
)
len
=
GIT_OID_HEXSZ
;
while
(
len
>
1
)
{
if
(
*
a
!=
*
b
)
return
1
;
a
++
;
b
++
;
len
-=
2
;
};
if
(
len
)
if
((
*
a
^
*
b
)
&
0xf0
)
return
1
;
return
0
;
return
git_oid_raw_ncmp
(
oid_a
->
id
,
oid_b
->
id
,
len
);
}
int
git_oid_strcmp
(
const
git_oid
*
oid_a
,
const
char
*
str
)
...
...
src/libgit2/oid.h
View file @
6d8c7cab
...
...
@@ -25,6 +25,29 @@ extern const git_oid git_oid__empty_tree_sha1;
*/
char
*
git_oid_allocfmt
(
const
git_oid
*
id
);
GIT_INLINE
(
int
)
git_oid_raw_ncmp
(
const
unsigned
char
*
sha1
,
const
unsigned
char
*
sha2
,
size_t
len
)
{
if
(
len
>
GIT_OID_HEXSZ
)
len
=
GIT_OID_HEXSZ
;
while
(
len
>
1
)
{
if
(
*
sha1
!=
*
sha2
)
return
1
;
sha1
++
;
sha2
++
;
len
-=
2
;
};
if
(
len
)
if
((
*
sha1
^
*
sha2
)
&
0xf0
)
return
1
;
return
0
;
}
GIT_INLINE
(
int
)
git_oid_raw_cmp
(
const
unsigned
char
*
sha1
,
const
unsigned
char
*
sha2
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment