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
82a1aab6
Commit
82a1aab6
authored
Mar 18, 2016
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iterator: move the index into the iterator itself
parent
de034cd2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
36 deletions
+15
-36
src/iterator.c
+8
-33
src/iterator.h
+7
-3
No files found.
src/iterator.c
View file @
82a1aab6
...
...
@@ -1321,7 +1321,7 @@ static int is_submodule(
}
}
if
(
!
is_submodule
&&
iter
->
index
)
{
if
(
!
is_submodule
&&
iter
->
base
.
index
)
{
size_t
pos
;
error
=
git_index_snapshot_find
(
&
pos
,
...
...
@@ -2090,7 +2090,7 @@ static int iterator_for_filesystem(
if
(
tree
&&
(
error
=
git_tree_dup
(
&
iter
->
tree
,
tree
))
<
0
)
goto
on_error
;
if
((
iter
->
index
=
index
)
!=
NULL
&&
if
((
iter
->
base
.
index
=
index
)
!=
NULL
&&
(
error
=
git_index_snapshot_new
(
&
iter
->
index_snapshot
,
index
))
<
0
)
goto
on_error
;
...
...
@@ -2156,7 +2156,6 @@ int git_iterator_for_workdir_ext(
typedef
struct
{
git_iterator
base
;
git_iterator_callbacks
cb
;
git_index
*
index
;
git_vector
entries
;
git_vector_cmp
entry_srch
;
size_t
current
;
...
...
@@ -2389,8 +2388,8 @@ static int index_iterator__reset_range(
static
void
index_iterator__free
(
git_iterator
*
self
)
{
index_iterator
*
ii
=
(
index_iterator
*
)
self
;
git_index_snapshot_release
(
&
ii
->
entries
,
ii
->
index
);
ii
->
index
=
NULL
;
git_index_snapshot_release
(
&
ii
->
entries
,
ii
->
base
.
index
);
ii
->
base
.
index
=
NULL
;
git_buf_free
(
&
ii
->
partial
);
}
...
...
@@ -2408,7 +2407,7 @@ int git_iterator_for_index(
git__free
(
ii
);
return
error
;
}
ii
->
index
=
index
;
ii
->
base
.
index
=
index
;
ITERATOR_BASE_INIT
(
ii
,
index
,
INDEX
,
repo
);
...
...
@@ -2434,6 +2433,9 @@ int git_iterator_for_index(
}
/* Iterator API */
void
git_iterator_free
(
git_iterator
*
iter
)
{
if
(
iter
==
NULL
)
...
...
@@ -2450,33 +2452,6 @@ void git_iterator_free(git_iterator *iter)
git__free
(
iter
);
}
int
git_iterator_cmp
(
git_iterator
*
iter
,
const
char
*
path_prefix
)
{
const
git_index_entry
*
entry
;
/* a "done" iterator is after every prefix */
if
(
git_iterator_current
(
&
entry
,
iter
)
<
0
||
entry
==
NULL
)
return
1
;
/* a NULL prefix is after any valid iterator */
if
(
!
path_prefix
)
return
-
1
;
return
iter
->
prefixcomp
(
entry
->
path
,
path_prefix
);
}
git_index
*
git_iterator_index
(
git_iterator
*
iter
)
{
if
(
iter
->
type
==
GIT_ITERATOR_TYPE_INDEX
)
return
((
index_iterator
*
)
iter
)
->
index
;
if
(
iter
->
type
==
GIT_ITERATOR_TYPE_FS
||
iter
->
type
==
GIT_ITERATOR_TYPE_WORKDIR
)
return
((
filesystem_iterator
*
)
iter
)
->
index
;
return
NULL
;
}
int
git_iterator_walk
(
git_iterator
**
iterators
,
size_t
cnt
,
...
...
src/iterator.h
View file @
82a1aab6
...
...
@@ -77,7 +77,9 @@ typedef struct {
struct
git_iterator
{
git_iterator_type_t
type
;
git_iterator_callbacks
*
cb
;
git_repository
*
repo
;
git_index
*
index
;
char
*
start
;
size_t
start_len
;
...
...
@@ -260,6 +262,11 @@ GIT_INLINE(git_repository *) git_iterator_owner(git_iterator *iter)
return
iter
->
repo
;
}
GIT_INLINE
(
git_index
*
)
git_iterator_index
(
git_iterator
*
iter
)
{
return
iter
->
index
;
}
GIT_INLINE
(
git_iterator_flag_t
)
git_iterator_flags
(
git_iterator
*
iter
)
{
return
iter
->
flags
;
...
...
@@ -282,9 +289,6 @@ extern bool git_iterator_current_is_ignored(git_iterator *iter);
extern
bool
git_iterator_current_tree_is_ignored
(
git_iterator
*
iter
);
extern
int
git_iterator_cmp
(
git_iterator
*
iter
,
const
char
*
path_prefix
);
/**
* Get full path of the current item from a workdir iterator. This will
* return NULL for a non-workdir iterator. The git_buf is still owned by
...
...
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