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
79b0c8c8
Commit
79b0c8c8
authored
Nov 21, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iterator: use GIT_ASSERT
parent
cd2fe662
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
22 deletions
+31
-22
src/diff_generate.c
+3
-2
src/iterator.c
+27
-19
src/iterator.h
+1
-1
No files found.
src/diff_generate.c
View file @
79b0c8c8
...
...
@@ -1206,8 +1206,9 @@ int git_diff__from_iterators(
/* make iterators have matching icase behavior */
if
(
DIFF_FLAG_IS_SET
(
diff
,
GIT_DIFF_IGNORE_CASE
))
{
git_iterator_set_ignore_case
(
old_iter
,
true
);
git_iterator_set_ignore_case
(
new_iter
,
true
);
if
((
error
=
git_iterator_set_ignore_case
(
old_iter
,
true
))
<
0
||
(
error
=
git_iterator_set_ignore_case
(
new_iter
,
true
))
<
0
)
goto
cleanup
;
}
/* finish initialization */
...
...
src/iterator.c
View file @
79b0c8c8
...
...
@@ -330,7 +330,7 @@ static iterator_pathlist_search_t iterator_pathlist_search(
break
;
/* an exact match would have been matched by the bsearch above */
assert
(
p
[
path_len
]
);
GIT_ASSERT_WITH_RETVAL
(
p
[
path_len
],
ITERATOR_PATHLIST_NONE
);
/* is this a literal directory entry (eg `foo/`) or a file beneath */
if
(
p
[
path_len
]
==
'/'
)
{
...
...
@@ -678,14 +678,14 @@ done:
return
error
;
}
static
void
tree_iterator_frame_pop
(
tree_iterator
*
iter
)
static
int
tree_iterator_frame_pop
(
tree_iterator
*
iter
)
{
tree_iterator_frame
*
frame
;
git_buf
*
buf
=
NULL
;
git_tree
*
tree
;
size_t
i
;
assert
(
iter
->
frames
.
size
);
GIT_ASSERT
(
iter
->
frames
.
size
);
frame
=
git_array_pop
(
iter
->
frames
);
...
...
@@ -705,6 +705,8 @@ static void tree_iterator_frame_pop(tree_iterator *iter)
git_vector_free
(
&
frame
->
similar_trees
);
git_buf_dispose
(
&
frame
->
path
);
return
0
;
}
static
int
tree_iterator_current
(
...
...
@@ -760,7 +762,9 @@ static int tree_iterator_advance(const git_index_entry **out, git_iterator *i)
/* no more entries in this frame. pop the frame out */
if
(
frame
->
next_idx
==
frame
->
entries
.
length
)
{
tree_iterator_frame_pop
(
iter
);
if
((
error
=
tree_iterator_frame_pop
(
iter
))
<
0
)
break
;
continue
;
}
...
...
@@ -855,7 +859,7 @@ static int tree_iterator_advance_into(
* we will have pushed a new (empty) frame on to the stack for this
* new directory. since it's empty, its current_entry should be null.
*/
assert
(
iterator__do_autoexpand
(
i
)
^
(
prev_entry
!=
NULL
));
GIT_ASSERT
(
iterator__do_autoexpand
(
i
)
^
(
prev_entry
!=
NULL
));
if
(
prev_entry
)
{
if
(
!
git_tree_entry__is_tree
(
prev_entry
->
tree_entry
))
...
...
@@ -973,7 +977,7 @@ int git_iterator_current_tree_entry(
tree_iterator_frame
*
frame
;
tree_iterator_entry
*
entry
;
assert
(
i
->
type
==
GIT_ITERATOR_TREE
);
GIT_ASSERT
(
i
->
type
==
GIT_ITERATOR_TREE
);
iter
=
(
tree_iterator
*
)
i
;
...
...
@@ -990,11 +994,11 @@ int git_iterator_current_parent_tree(
tree_iterator
*
iter
;
tree_iterator_frame
*
frame
;
assert
(
i
->
type
==
GIT_ITERATOR_TREE
);
GIT_ASSERT
(
i
->
type
==
GIT_ITERATOR_TREE
);
iter
=
(
tree_iterator
*
)
i
;
assert
(
depth
<
iter
->
frames
.
size
);
GIT_ASSERT
(
depth
<
iter
->
frames
.
size
);
frame
=
&
iter
->
frames
.
ptr
[
iter
->
frames
.
size
-
depth
-
1
];
*
parent_tree
=
frame
->
tree
;
...
...
@@ -1388,7 +1392,7 @@ static int filesystem_iterator_frame_push(
if
((
error
=
git_path_diriter_fullpath
(
&
path
,
&
path_len
,
&
diriter
))
<
0
)
goto
done
;
assert
(
path_len
>
iter
->
root_len
);
GIT_ASSERT
(
path_len
>
iter
->
root_len
);
/* remove the prefix if requested */
path
+=
iter
->
root_len
;
...
...
@@ -1469,17 +1473,19 @@ done:
return
error
;
}
GIT_INLINE
(
void
)
filesystem_iterator_frame_pop
(
filesystem_iterator
*
iter
)
GIT_INLINE
(
int
)
filesystem_iterator_frame_pop
(
filesystem_iterator
*
iter
)
{
filesystem_iterator_frame
*
frame
;
assert
(
iter
->
frames
.
size
);
GIT_ASSERT
(
iter
->
frames
.
size
);
frame
=
git_array_pop
(
iter
->
frames
);
filesystem_iterator_frame_pop_ignores
(
iter
);
git_pool_clear
(
&
frame
->
entry_pool
);
git_vector_free
(
&
frame
->
entries
);
return
0
;
}
static
void
filesystem_iterator_set_current
(
...
...
@@ -1646,7 +1652,7 @@ static int filesystem_iterator_advance_into(
* we will have pushed a new (empty) frame on to the stack for this
* new directory. since it's empty, its current_entry should be null.
*/
assert
(
iterator__do_autoexpand
(
i
)
^
(
prev_entry
!=
NULL
));
GIT_ASSERT
(
iterator__do_autoexpand
(
i
)
^
(
prev_entry
!=
NULL
));
if
(
prev_entry
)
{
if
(
prev_entry
->
st
.
st_mode
!=
GIT_FILEMODE_COMMIT
&&
...
...
@@ -1762,12 +1768,13 @@ static int filesystem_iterator_advance_over(
*
out
=
NULL
;
*
status
=
GIT_ITERATOR_STATUS_NORMAL
;
assert
(
iterator__has_been_accessed
(
i
));
GIT_ASSERT
(
iterator__has_been_accessed
(
i
));
current_frame
=
filesystem_iterator_current_frame
(
iter
);
assert
(
current_frame
);
GIT_ASSERT
(
current_frame
);
current_entry
=
filesystem_iterator_current_entry
(
current_frame
);
assert
(
current_entry
);
GIT_ASSERT
(
current_entry
);
if
((
error
=
git_iterator_current
(
&
entry
,
i
))
<
0
)
return
error
;
...
...
@@ -2065,8 +2072,8 @@ static bool index_iterator_create_pseudotree(
static
int
index_iterator_skip_pseudotree
(
index_iterator
*
iter
)
{
assert
(
iterator__has_been_accessed
(
&
iter
->
base
));
assert
(
S_ISDIR
(
iter
->
entry
->
mode
));
GIT_ASSERT
(
iterator__has_been_accessed
(
&
iter
->
base
));
GIT_ASSERT
(
S_ISDIR
(
iter
->
entry
->
mode
));
while
(
true
)
{
const
git_index_entry
*
next_entry
=
NULL
;
...
...
@@ -2280,10 +2287,11 @@ int git_iterator_reset_range(
return
i
->
cb
->
reset
(
i
);
}
void
git_iterator_set_ignore_case
(
git_iterator
*
i
,
bool
ignore_case
)
int
git_iterator_set_ignore_case
(
git_iterator
*
i
,
bool
ignore_case
)
{
assert
(
!
iterator__has_been_accessed
(
i
));
GIT_ASSERT
(
!
iterator__has_been_accessed
(
i
));
iterator_set_ignore_case
(
i
,
ignore_case
);
return
0
;
}
void
git_iterator_free
(
git_iterator
*
iter
)
...
...
src/iterator.h
View file @
79b0c8c8
...
...
@@ -263,7 +263,7 @@ GIT_INLINE(bool) git_iterator_ignore_case(git_iterator *iter)
return
((
iter
->
flags
&
GIT_ITERATOR_IGNORE_CASE
)
!=
0
);
}
extern
void
git_iterator_set_ignore_case
(
extern
int
git_iterator_set_ignore_case
(
git_iterator
*
iter
,
bool
ignore_case
);
extern
int
git_iterator_current_tree_entry
(
...
...
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