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
32618937
Unverified
Commit
32618937
authored
Dec 20, 2023
by
Edward Thomson
Committed by
GitHub
Dec 20, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6700 from libgit2/ethomson/ubfix
Fix some bugs caught by UBscan
parents
2dee5bd8
01d2adcb
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
12 deletions
+38
-12
src/libgit2/iterator.c
+10
-4
src/libgit2/refs.c
+6
-0
src/libgit2/refs.h
+6
-0
src/util/util.c
+2
-2
tests/libgit2/iterator/workdir.c
+3
-3
tests/libgit2/network/remote/rename.c
+1
-1
tests/libgit2/odb/sorting.c
+6
-1
tests/libgit2/remote/fetch.c
+4
-1
No files found.
src/libgit2/iterator.c
View file @
32618937
...
...
@@ -26,9 +26,10 @@
#define iterator__ignore_dot_git(I) iterator__flag(I,IGNORE_DOT_GIT)
#define iterator__descend_symlinks(I) iterator__flag(I,DESCEND_SYMLINKS)
static
void
iterator_set_ignore_case
(
git_iterator
*
iter
,
bool
ignore_case
)
{
int
(
*
vector_cmp
)(
const
void
*
a
,
const
void
*
b
);
if
(
ignore_case
)
iter
->
flags
|=
GIT_ITERATOR_IGNORE_CASE
;
else
...
...
@@ -39,7 +40,9 @@ static void iterator_set_ignore_case(git_iterator *iter, bool ignore_case)
iter
->
prefixcomp
=
ignore_case
?
git__prefixcmp_icase
:
git__prefixcmp
;
iter
->
entry_srch
=
ignore_case
?
git_index_entry_isrch
:
git_index_entry_srch
;
git_vector_set_cmp
(
&
iter
->
pathlist
,
(
git_vector_cmp
)
iter
->
strcomp
);
vector_cmp
=
ignore_case
?
git__strcasecmp_cb
:
git__strcmp_cb
;
git_vector_set_cmp
(
&
iter
->
pathlist
,
vector_cmp
);
}
static
int
iterator_range_init
(
...
...
@@ -299,6 +302,7 @@ typedef enum {
static
iterator_pathlist_search_t
iterator_pathlist_search
(
git_iterator
*
iter
,
const
char
*
path
,
size_t
path_len
)
{
int
(
*
vector_cmp
)(
const
void
*
a
,
const
void
*
b
);
const
char
*
p
;
size_t
idx
;
int
error
;
...
...
@@ -308,8 +312,10 @@ static iterator_pathlist_search_t iterator_pathlist_search(
git_vector_sort
(
&
iter
->
pathlist
);
error
=
git_vector_bsearch2
(
&
idx
,
&
iter
->
pathlist
,
(
git_vector_cmp
)
iter
->
strcomp
,
path
);
vector_cmp
=
(
iter
->
flags
&
GIT_ITERATOR_IGNORE_CASE
)
!=
0
?
git__strcasecmp_cb
:
git__strcmp_cb
;
error
=
git_vector_bsearch2
(
&
idx
,
&
iter
->
pathlist
,
vector_cmp
,
path
);
/* the given path was found in the pathlist. since the pathlist only
* matches directories when they're suffixed with a '/', analyze the
...
...
src/libgit2/refs.c
View file @
32618937
...
...
@@ -1080,6 +1080,12 @@ int git_reference_cmp(
return
git_oid__cmp
(
&
ref1
->
target
.
oid
,
&
ref2
->
target
.
oid
);
}
int
git_reference__cmp_cb
(
const
void
*
a
,
const
void
*
b
)
{
return
git_reference_cmp
(
(
const
git_reference
*
)
a
,
(
const
git_reference
*
)
b
);
}
/*
* Starting with the reference given by `ref_name`, follows symbolic
* references until a direct reference is found and updated the OID
...
...
src/libgit2/refs.h
View file @
32618937
...
...
@@ -92,6 +92,12 @@ int git_reference__is_tag(const char *ref_name);
int
git_reference__is_note
(
const
char
*
ref_name
);
const
char
*
git_reference__shorthand
(
const
char
*
name
);
/*
* A `git_reference_cmp` wrapper suitable for passing to generic
* comparators, like `vector_cmp` / `tsort` / etc.
*/
int
git_reference__cmp_cb
(
const
void
*
a
,
const
void
*
b
);
/**
* Lookup a reference by name and try to resolve to an OID.
*
...
...
src/util/util.c
View file @
32618937
...
...
@@ -623,12 +623,12 @@ int git__bsearch_r(
*/
int
git__strcmp_cb
(
const
void
*
a
,
const
void
*
b
)
{
return
strcmp
((
const
char
*
)
a
,
(
const
char
*
)
b
);
return
git__
strcmp
((
const
char
*
)
a
,
(
const
char
*
)
b
);
}
int
git__strcasecmp_cb
(
const
void
*
a
,
const
void
*
b
)
{
return
strcasecmp
((
const
char
*
)
a
,
(
const
char
*
)
b
);
return
git__
strcasecmp
((
const
char
*
)
a
,
(
const
char
*
)
b
);
}
int
git__parse_bool
(
int
*
out
,
const
char
*
value
)
...
...
tests/libgit2/iterator/workdir.c
View file @
32618937
...
...
@@ -585,9 +585,9 @@ void test_iterator_workdir__filesystem(void)
expect_iterator_items
(
i
,
5
,
expect_noauto
,
18
,
expect_trees
);
git_iterator_free
(
i
);
git__tsort
((
void
**
)
expect_base
,
8
,
(
git__tsort_cmp
)
git__strcasecmp
);
git__tsort
((
void
**
)
expect_trees
,
18
,
(
git__tsort_cmp
)
git__strcasecmp
);
git__tsort
((
void
**
)
expect_noauto
,
5
,
(
git__tsort_cmp
)
git__strcasecmp
);
git__tsort
((
void
**
)
expect_base
,
8
,
git__strcasecmp_cb
);
git__tsort
((
void
**
)
expect_trees
,
18
,
git__strcasecmp_cb
);
git__tsort
((
void
**
)
expect_noauto
,
5
,
git__strcasecmp_cb
);
i_opts
.
flags
=
GIT_ITERATOR_IGNORE_CASE
;
cl_git_pass
(
git_iterator_for_filesystem
(
&
i
,
"status/subdir"
,
&
i_opts
));
...
...
tests/libgit2/network/remote/rename.c
View file @
32618937
...
...
@@ -216,7 +216,7 @@ void test_network_remote_rename__symref_head(void)
cl_assert_equal_i
(
0
,
problems
.
count
);
git_strarray_dispose
(
&
problems
);
cl_git_pass
(
git_vector_init
(
&
refs
,
2
,
(
git_vector_cmp
)
git_reference_cmp
));
cl_git_pass
(
git_vector_init
(
&
refs
,
2
,
git_reference__cmp_cb
));
cl_git_pass
(
git_branch_iterator_new
(
&
iter
,
_repo
,
GIT_BRANCH_REMOTE
));
while
((
error
=
git_branch_next
(
&
ref
,
&
btype
,
iter
))
==
0
)
{
...
...
tests/libgit2/odb/sorting.c
View file @
32618937
...
...
@@ -7,6 +7,11 @@ typedef struct {
size_t
position
;
}
fake_backend
;
static
void
odb_backend_free
(
git_odb_backend
*
odb
)
{
git__free
(
odb
);
}
static
git_odb_backend
*
new_backend
(
size_t
position
)
{
fake_backend
*
b
;
...
...
@@ -15,7 +20,7 @@ static git_odb_backend *new_backend(size_t position)
if
(
b
==
NULL
)
return
NULL
;
b
->
base
.
free
=
(
void
(
*
)(
git_odb_backend
*
))
git_
_free
;
b
->
base
.
free
=
odb_backend
_free
;
b
->
base
.
version
=
GIT_ODB_BACKEND_VERSION
;
b
->
position
=
position
;
return
(
git_odb_backend
*
)
b
;
...
...
tests/libgit2/remote/fetch.c
View file @
32618937
...
...
@@ -75,6 +75,7 @@ static void do_time_travelling_fetch(git_oid *commit1id, git_oid *commit2id,
/* create two commits in repo 1 and a reference to them */
{
git_oid
empty_tree_id
;
git_commit
*
commit1
;
git_tree
*
empty_tree
;
git_signature
*
sig
;
git_treebuilder
*
tb
;
...
...
@@ -84,10 +85,12 @@ static void do_time_travelling_fetch(git_oid *commit1id, git_oid *commit2id,
cl_git_pass
(
git_signature_default
(
&
sig
,
repo1
));
cl_git_pass
(
git_commit_create
(
commit1id
,
repo1
,
REPO1_REFNAME
,
sig
,
sig
,
NULL
,
"one"
,
empty_tree
,
0
,
NULL
));
cl_git_pass
(
git_commit_lookup
(
&
commit1
,
repo1
,
commit1id
));
cl_git_pass
(
git_commit_create_v
(
commit2id
,
repo1
,
REPO1_REFNAME
,
sig
,
sig
,
NULL
,
"two"
,
empty_tree
,
1
,
commit1
id
));
sig
,
NULL
,
"two"
,
empty_tree
,
1
,
commit1
));
git_tree_free
(
empty_tree
);
git_commit_free
(
commit1
);
git_signature_free
(
sig
);
git_treebuilder_free
(
tb
);
}
...
...
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