Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
libgit2/src/iterator.h at development · TNick/libgit2 · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
TNick
libgit2
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
development
Breadcrumbs
libgit2
/
src
/
iterator.h
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
212 lines (176 loc) · 6.09 KB
development
Breadcrumbs
libgit2
/
src
/
iterator.h
Copy path
Top
File metadata and controls
Code
Blame
212 lines (176 loc) · 6.09 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef
INCLUDE_iterator_h__
#define
INCLUDE_iterator_h__
#include
"common.h"
#include
"git2/index.h"
#include
"vector.h"
#include
"buffer.h"
#define
ITERATOR_PREFIXCMP
(
ITER
,
STR
,
PREFIX
) \
(((ITER).flags & GIT_ITERATOR_IGNORE_CASE) != 0 ? \
git__prefixcmp_icase((STR), (PREFIX)) : \
git__prefixcmp((STR), (PREFIX)))
typedef
struct
git_iterator
git_iterator
;
typedef
enum
{
GIT_ITERATOR_TYPE_EMPTY
=
0
,
GIT_ITERATOR_TYPE_TREE
=
1
,
GIT_ITERATOR_TYPE_INDEX
=
2
,
GIT_ITERATOR_TYPE_WORKDIR
=
3
,
GIT_ITERATOR_TYPE_SPOOLANDSORT
=
4
}
git_iterator_type_t
;
typedef
enum
{
GIT_ITERATOR_IGNORE_CASE
=
(
1
<<
0
),
/* ignore_case */
GIT_ITERATOR_DONT_IGNORE_CASE
=
(
1
<<
1
),
/* force ignore_case off */
}
git_iterator_flag_t
;
typedef
struct
{
int
(
*
current
)(
git_iterator
*
,
const
git_index_entry
*
*
);
int
(
*
at_end
)(
git_iterator
*
);
int
(
*
advance
)(
git_iterator
*
,
const
git_index_entry
*
*
);
int
(
*
seek
)(
git_iterator
*
,
const
char
*
prefix
);
int
(
*
reset
)(
git_iterator
*
,
const
char
*
start
,
const
char
*
end
);
void
(
*
free
)(
git_iterator
*
);
}
git_iterator_callbacks
;
struct
git_iterator
{
git_iterator_type_t
type
;
git_iterator_callbacks
*
cb
;
git_repository
*
repo
;
char
*
start
;
char
*
end
;
int
(
*
prefixcomp
)(
const
char
*
str
,
const
char
*
prefix
);
unsigned
int
flags
;
};
extern
int
git_iterator_for_nothing
(
git_iterator
*
*
out
,
git_iterator_flag_t
flags
);
/* tree iterators will match the ignore_case value from the index of the
* repository, unless you override with a non-zero flag value
*/
extern
int
git_iterator_for_tree_range
(
git_iterator
*
*
out
,
git_tree
*
tree
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
);
GIT_INLINE
(
int
)
git_iterator_for_tree
(
git_iterator
*
*
out
,
git_tree
*
tree
)
{
return
git_iterator_for_tree_range
(
out
,
tree
,
0
,
NULL
,
NULL
);
}
/* index iterators will take the ignore_case value from the index; the
* ignore_case flags are not used
*/
extern
int
git_iterator_for_index_range
(
git_iterator
*
*
out
,
git_index
*
index
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
);
GIT_INLINE
(
int
)
git_iterator_for_index
(
git_iterator
*
*
out
,
git_index
*
index
)
{
return
git_iterator_for_index_range
(
out
,
index
,
0
,
NULL
,
NULL
);
}
/* workdir iterators will match the ignore_case value from the index of the
* repository, unless you override with a non-zero flag value
*/
extern
int
git_iterator_for_workdir_range
(
git_iterator
*
*
out
,
git_repository
*
repo
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
);
GIT_INLINE
(
int
)
git_iterator_for_workdir
(
git_iterator
*
*
out
,
git_repository
*
repo
)
{
return
git_iterator_for_workdir_range
(
out
,
repo
,
0
,
NULL
,
NULL
);
}
extern
void
git_iterator_free
(
git_iterator
*
iter
);
/* Spool all iterator values, resort with alternative ignore_case value
* and replace callbacks with spoolandsort alternates.
*/
extern
int
git_iterator_spoolandsort_push
(
git_iterator
*
iter
,
bool
ignore_case
);
/* Restore original callbacks - not required in most circumstances */
extern
void
git_iterator_spoolandsort_pop
(
git_iterator
*
iter
);
/* Entry is not guaranteed to be fully populated. For a tree iterator,
* we will only populate the mode, oid and path, for example. For a workdir
* iterator, we will not populate the oid.
*
* You do not need to free the entry. It is still "owned" by the iterator.
* Once you call `git_iterator_advance`, then content of the old entry is
* no longer guaranteed to be valid.
*/
GIT_INLINE
(
int
)
git_iterator_current
(
git_iterator
*
iter
,
const
git_index_entry
*
*
entry
)
{
return
iter
->
cb
->
current
(
iter
,
entry
);
}
GIT_INLINE
(
int
)
git_iterator_at_end
(
git_iterator
*
iter
)
{
return
iter
->
cb
->
at_end
(
iter
);
}
GIT_INLINE
(
int
)
git_iterator_advance
(
git_iterator
*
iter
,
const
git_index_entry
*
*
entry
)
{
return
iter
->
cb
->
advance
(
iter
,
entry
);
}
GIT_INLINE
(
int
)
git_iterator_seek
(
git_iterator
*
iter
,
const
char
*
prefix
)
{
return
iter
->
cb
->
seek
(
iter
,
prefix
);
}
GIT_INLINE
(
int
)
git_iterator_reset
(
git_iterator
*
iter
,
const
char
*
start
,
const
char
*
end
)
{
return
iter
->
cb
->
reset
(
iter
,
start
,
end
);
}
GIT_INLINE
(
git_iterator_type_t
)
git_iterator_type
(
git_iterator
*
iter
)
{
return
iter
->
type
;
}
GIT_INLINE
(
git_repository
*
)
git_iterator_owner
(
git_iterator
*
iter
)
{
return
iter
->
repo
;
}
GIT_INLINE
(
git_iterator_flag_t
)
git_iterator_flags
(
git_iterator
*
iter
)
{
return
iter
->
flags
;
}
GIT_INLINE
(
bool
)
git_iterator_ignore_case
(
git_iterator
*
iter
)
{
return
((
iter
->
flags
&
GIT_ITERATOR_IGNORE_CASE
)
!=
0
);
}
extern
int
git_iterator_current_tree_entry
(
git_iterator
*
iter
,
const
git_tree_entry
*
*
tree_entry
);
extern
int
git_iterator_current_parent_tree
(
git_iterator
*
iter
,
const
char
*
parent_path
,
const
git_tree
*
*
tree_ptr
);
extern
int
git_iterator_current_is_ignored
(
git_iterator
*
iter
);
/**
* Iterate into a workdir directory.
*
* Workdir iterators do not automatically descend into directories (so that
* when comparing two iterator entries you can detect a newly created
* directory in the workdir). As a result, you may get S_ISDIR items from
* a workdir iterator. If you wish to iterate over the contents of the
* directories you encounter, then call this function when you encounter
* a directory.
*
* If there are no files in the directory, this will end up acting like a
* regular advance and will skip past the directory, so you should be
* prepared for that case.
*
* On non-workdir iterators or if not pointing at a directory, this is a
* no-op and will not advance the iterator.
*/
extern
int
git_iterator_advance_into_directory
(
git_iterator
*
iter
,
const
git_index_entry
*
*
entry
);
extern
int
git_iterator_cmp
(
git_iterator
*
iter
,
const
char
*
path_prefix
);
/**
* Get the full path of the current item from a workdir iterator.
* This will return NULL for a non-workdir iterator.
*/
extern
int
git_iterator_current_workdir_path
(
git_iterator
*
iter
,
git_buf
*
*
path
);
extern
git_index
*
git_iterator_index_get_index
(
git_iterator
*
iter
);
extern
git_iterator_type_t
git_iterator_inner_type
(
git_iterator
*
iter
);
#endif
You can’t perform that action at this time.