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
ed1c6446
Commit
ed1c6446
authored
Jul 28, 2015
by
Edward Thomson
Committed by
Edward Thomson
Aug 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iterator: use an options struct instead of args
parent
126932eb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
204 additions
and
140 deletions
+204
-140
src/checkout.c
+16
-10
src/diff.c
+25
-19
src/index.c
+5
-4
src/iterator.c
+20
-25
src/iterator.h
+18
-19
src/merge.c
+24
-11
src/notes.c
+1
-1
src/pathspec.c
+12
-12
src/refdb_fs.c
+4
-2
src/stash.c
+17
-12
src/submodule.c
+2
-2
tests/diff/iterator.c
+46
-14
tests/merge/trees/treediff.c
+6
-6
tests/repo/iterator.c
+0
-0
tests/submodule/status.c
+4
-2
tests/threads/iterator.c
+4
-1
No files found.
src/checkout.c
View file @
ed1c6446
...
...
@@ -2471,11 +2471,12 @@ int git_checkout_iterator(
{
int
error
=
0
;
git_iterator
*
baseline
=
NULL
,
*
workdir
=
NULL
;
git_iterator_options
baseline_opts
=
GIT_ITERATOR_OPTIONS_INIT
,
workdir_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
checkout_data
data
=
{
0
};
git_diff_options
diff_opts
=
GIT_DIFF_OPTIONS_INIT
;
uint32_t
*
actions
=
NULL
;
size_t
*
counts
=
NULL
;
git_iterator_flag_t
iterflags
=
0
;
/* initialize structures and options */
error
=
checkout_data_init
(
&
data
,
target
,
opts
);
...
...
@@ -2499,25 +2500,30 @@ int git_checkout_iterator(
/* set up iterators */
iter
flags
=
git_iterator_ignore_case
(
target
)
?
workdir_opts
.
flags
=
git_iterator_ignore_case
(
target
)
?
GIT_ITERATOR_IGNORE_CASE
:
GIT_ITERATOR_DONT_IGNORE_CASE
;
workdir_opts
.
flags
|=
GIT_ITERATOR_DONT_AUTOEXPAND
;
workdir_opts
.
start
=
data
.
pfx
;
workdir_opts
.
end
=
data
.
pfx
;
if
((
error
=
git_iterator_reset
(
target
,
data
.
pfx
,
data
.
pfx
))
<
0
||
(
error
=
git_iterator_for_workdir_ext
(
&
workdir
,
data
.
repo
,
data
.
opts
.
target_directory
,
index
,
NULL
,
iterflags
|
GIT_ITERATOR_DONT_AUTOEXPAND
,
data
.
pfx
,
data
.
pfx
))
<
0
)
&
workdir_opts
))
<
0
)
goto
cleanup
;
baseline_opts
.
flags
=
git_iterator_ignore_case
(
target
)
?
GIT_ITERATOR_IGNORE_CASE
:
GIT_ITERATOR_DONT_IGNORE_CASE
;
baseline_opts
.
start
=
data
.
pfx
;
baseline_opts
.
end
=
data
.
pfx
;
if
(
data
.
opts
.
baseline_index
)
{
if
((
error
=
git_iterator_for_index
(
&
baseline
,
data
.
opts
.
baseline_index
,
iterflags
,
data
.
pfx
,
data
.
pfx
))
<
0
)
&
baseline
,
data
.
opts
.
baseline_index
,
&
baseline_opts
))
<
0
)
goto
cleanup
;
}
else
{
if
((
error
=
git_iterator_for_tree
(
&
baseline
,
data
.
opts
.
baseline
,
iterflags
,
data
.
pfx
,
data
.
pfx
))
<
0
)
&
baseline
,
data
.
opts
.
baseline
,
&
baseline_opts
))
<
0
)
goto
cleanup
;
}
...
...
@@ -2625,7 +2631,7 @@ int git_checkout_index(
return
error
;
GIT_REFCOUNT_INC
(
index
);
if
(
!
(
error
=
git_iterator_for_index
(
&
index_i
,
index
,
0
,
NULL
,
NULL
)))
if
(
!
(
error
=
git_iterator_for_index
(
&
index_i
,
index
,
NULL
)))
error
=
git_checkout_iterator
(
index_i
,
index
,
opts
);
if
(
owned
)
...
...
@@ -2681,7 +2687,7 @@ int git_checkout_tree(
if
((
error
=
git_repository_index
(
&
index
,
repo
))
<
0
)
return
error
;
if
(
!
(
error
=
git_iterator_for_tree
(
&
tree_i
,
tree
,
0
,
NULL
,
NULL
)))
if
(
!
(
error
=
git_iterator_for_tree
(
&
tree_i
,
tree
,
NULL
)))
error
=
git_checkout_iterator
(
tree_i
,
index
,
opts
);
git_iterator_free
(
tree_i
);
...
...
src/diff.c
View file @
ed1c6446
...
...
@@ -1264,9 +1264,17 @@ cleanup:
return
error
;
}
#define DIFF_FROM_ITERATORS(MAKE_FIRST,
MAKE
_SECOND) do { \
#define DIFF_FROM_ITERATORS(MAKE_FIRST,
FLAGS_FIRST, MAKE_SECOND, FLAGS
_SECOND) do { \
git_iterator *a = NULL, *b = NULL; \
char *pfx = opts ? git_pathspec_prefix(&opts->pathspec) : NULL; \
git_iterator_options a_opts = GIT_ITERATOR_OPTIONS_INIT, \
b_opts = GIT_ITERATOR_OPTIONS_INIT; \
a_opts.flags = FLAGS_FIRST; \
a_opts.start = pfx; \
a_opts.end = pfx; \
b_opts.flags = FLAGS_SECOND; \
b_opts.start = pfx; \
b_opts.end = pfx; \
GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \
if (!(error = MAKE_FIRST) && !(error = MAKE_SECOND)) \
error = git_diff__from_iterators(diff, repo, a, b, opts); \
...
...
@@ -1280,8 +1288,8 @@ int git_diff_tree_to_tree(
git_tree
*
new_tree
,
const
git_diff_options
*
opts
)
{
int
error
=
0
;
git_iterator_flag_t
iflag
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
int
error
=
0
;
assert
(
diff
&&
repo
);
...
...
@@ -1293,8 +1301,8 @@ int git_diff_tree_to_tree(
iflag
=
GIT_ITERATOR_IGNORE_CASE
;
DIFF_FROM_ITERATORS
(
git_iterator_for_tree
(
&
a
,
old_tree
,
iflag
,
pfx
,
pfx
)
,
git_iterator_for_tree
(
&
b
,
new_tree
,
iflag
,
pfx
,
pfx
)
git_iterator_for_tree
(
&
a
,
old_tree
,
&
a_opts
),
iflag
,
git_iterator_for_tree
(
&
b
,
new_tree
,
&
b_opts
),
iflag
);
return
error
;
...
...
@@ -1318,10 +1326,10 @@ int git_diff_tree_to_index(
git_index
*
index
,
const
git_diff_options
*
opts
)
{
int
error
=
0
;
bool
index_ignore_case
=
false
;
git_iterator_flag_t
iflag
=
GIT_ITERATOR_DONT_IGNORE_CASE
|
GIT_ITERATOR_INCLUDE_CONFLICTS
;
bool
index_ignore_case
=
false
;
int
error
=
0
;
assert
(
diff
&&
repo
);
...
...
@@ -1331,8 +1339,8 @@ int git_diff_tree_to_index(
index_ignore_case
=
index
->
ignore_case
;
DIFF_FROM_ITERATORS
(
git_iterator_for_tree
(
&
a
,
old_tree
,
iflag
,
pfx
,
pfx
)
,
git_iterator_for_index
(
&
b
,
index
,
iflag
,
pfx
,
pfx
)
git_iterator_for_tree
(
&
a
,
old_tree
,
&
a_opts
),
iflag
,
git_iterator_for_index
(
&
b
,
index
,
&
b_opts
),
iflag
);
/* if index is in case-insensitive order, re-sort deltas to match */
...
...
@@ -1356,10 +1364,11 @@ int git_diff_index_to_workdir(
return
error
;
DIFF_FROM_ITERATORS
(
git_iterator_for_index
(
&
a
,
index
,
GIT_ITERATOR_INCLUDE_CONFLICTS
,
pfx
,
pfx
),
git_iterator_for_workdir
(
&
b
,
repo
,
index
,
NULL
,
GIT_ITERATOR_DONT_AUTOEXPAND
,
pfx
,
pfx
)
git_iterator_for_index
(
&
a
,
index
,
&
a_opts
),
GIT_ITERATOR_INCLUDE_CONFLICTS
,
git_iterator_for_workdir
(
&
b
,
repo
,
index
,
NULL
,
&
b_opts
),
GIT_ITERATOR_DONT_AUTOEXPAND
);
if
(
!
error
&&
DIFF_FLAG_IS_SET
(
*
diff
,
GIT_DIFF_UPDATE_INDEX
)
&&
(
*
diff
)
->
index_updated
)
...
...
@@ -1383,9 +1392,8 @@ int git_diff_tree_to_workdir(
return
error
;
DIFF_FROM_ITERATORS
(
git_iterator_for_tree
(
&
a
,
old_tree
,
0
,
pfx
,
pfx
),
git_iterator_for_workdir
(
&
b
,
repo
,
index
,
old_tree
,
GIT_ITERATOR_DONT_AUTOEXPAND
,
pfx
,
pfx
)
git_iterator_for_tree
(
&
a
,
old_tree
,
&
a_opts
),
0
,
git_iterator_for_workdir
(
&
b
,
repo
,
index
,
old_tree
,
&
b_opts
),
GIT_ITERATOR_DONT_AUTOEXPAND
);
return
error
;
...
...
@@ -1433,10 +1441,8 @@ int git_diff_index_to_index(
assert
(
diff
&&
old_index
&&
new_index
);
DIFF_FROM_ITERATORS
(
git_iterator_for_index
(
&
a
,
old_index
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
pfx
,
pfx
),
git_iterator_for_index
(
&
b
,
new_index
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
pfx
,
pfx
)
git_iterator_for_index
(
&
a
,
old_index
,
&
a_opts
),
GIT_ITERATOR_DONT_IGNORE_CASE
,
git_iterator_for_index
(
&
b
,
new_index
,
&
b_opts
),
GIT_ITERATOR_DONT_IGNORE_CASE
);
/* if index is in case-insensitive order, re-sort deltas to match */
...
...
src/index.c
View file @
ed1c6446
...
...
@@ -2658,6 +2658,7 @@ int git_index_read_index(
remove_entries
=
GIT_VECTOR_INIT
;
git_iterator
*
index_iterator
=
NULL
;
git_iterator
*
new_iterator
=
NULL
;
git_iterator_options
opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
old_entry
,
*
new_entry
;
git_index_entry
*
entry
;
size_t
i
;
...
...
@@ -2667,10 +2668,10 @@ int git_index_read_index(
(
error
=
git_vector_init
(
&
remove_entries
,
index
->
entries
.
length
,
NULL
))
<
0
)
goto
done
;
if
((
error
=
git_iterator_for_index
(
&
index_iterator
,
index
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_index
(
&
new_iterator
,
(
git_index
*
)
new_index
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
)
opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
if
((
error
=
git_iterator_for_index
(
&
index_iterator
,
index
,
&
opts
))
<
0
||
(
error
=
git_iterator_for_index
(
&
new_iterator
,
(
git_index
*
)
new_index
,
&
opts
))
<
0
)
goto
done
;
if
(((
error
=
git_iterator_current
(
&
old_entry
,
index_iterator
))
<
0
&&
...
...
src/iterator.c
View file @
ed1c6446
...
...
@@ -31,12 +31,15 @@
(P)->base.cb = &(P)->cb; \
ITERATOR_SET_CB(P,NAME_LC); \
(P)->base.repo = (REPO); \
(P)->base.start = start ? git__strdup(start) : NULL; \
(P)->base.end = end ? git__strdup(end) : NULL; \
if ((start && !(P)->base.start) || (end && !(P)->base.end)) { \
(P)->base.start = options && options->start ? \
git__strdup(options->start) : NULL; \
(P)->base.end = options && options->end ? \
git__strdup(options->end) : NULL; \
if ((options && options->start && !(P)->base.start) || \
(options && options->end && !(P)->base.end)) { \
git__free(P); return -1; } \
(P)->base.prefixcomp = git__prefixcmp; \
(P)->base.flags =
flags & ~ITERATOR_CASE_FLAGS
; \
(P)->base.flags =
options ? options->flags & ~ITERATOR_CASE_FLAGS : 0
; \
if ((P)->base.flags & GIT_ITERATOR_DONT_AUTOEXPAND) \
(P)->base.flags |= GIT_ITERATOR_INCLUDE_TREES; \
} while (0)
...
...
@@ -149,9 +152,7 @@ typedef struct {
int
git_iterator_for_nothing
(
git_iterator
**
iter
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
)
git_iterator_options
*
options
)
{
empty_iterator
*
i
=
git__calloc
(
1
,
sizeof
(
empty_iterator
));
GITERR_CHECK_ALLOC
(
i
);
...
...
@@ -162,7 +163,7 @@ int git_iterator_for_nothing(
ITERATOR_BASE_INIT
(
i
,
empty
,
EMPTY
,
NULL
);
if
(
(
flags
&
GIT_ITERATOR_IGNORE_CASE
)
!=
0
)
if
(
options
&&
(
options
->
flags
&
GIT_ITERATOR_IGNORE_CASE
)
!=
0
)
i
->
base
.
flags
|=
GIT_ITERATOR_IGNORE_CASE
;
*
iter
=
(
git_iterator
*
)
i
;
...
...
@@ -607,15 +608,13 @@ static int tree_iterator__create_root_frame(tree_iterator *ti, git_tree *tree)
int
git_iterator_for_tree
(
git_iterator
**
iter
,
git_tree
*
tree
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
)
git_iterator_options
*
options
)
{
int
error
;
tree_iterator
*
ti
;
if
(
tree
==
NULL
)
return
git_iterator_for_nothing
(
iter
,
flags
,
start
,
end
);
return
git_iterator_for_nothing
(
iter
,
options
);
if
((
error
=
git_object_dup
((
git_object
**
)
&
tree
,
(
git_object
*
)
tree
))
<
0
)
return
error
;
...
...
@@ -625,7 +624,7 @@ int git_iterator_for_tree(
ITERATOR_BASE_INIT
(
ti
,
tree
,
TREE
,
git_tree_owner
(
tree
));
if
((
error
=
iterator__update_ignore_case
((
git_iterator
*
)
ti
,
flags
))
<
0
)
if
((
error
=
iterator__update_ignore_case
((
git_iterator
*
)
ti
,
options
?
options
->
flags
:
0
))
<
0
)
goto
fail
;
ti
->
strncomp
=
iterator__ignore_case
(
ti
)
?
git__strncasecmp
:
git__strncmp
;
...
...
@@ -860,9 +859,7 @@ static void index_iterator__free(git_iterator *self)
int
git_iterator_for_index
(
git_iterator
**
iter
,
git_index
*
index
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
)
git_iterator_options
*
options
)
{
int
error
=
0
;
index_iterator
*
ii
=
git__calloc
(
1
,
sizeof
(
index_iterator
));
...
...
@@ -876,7 +873,7 @@ int git_iterator_for_index(
ITERATOR_BASE_INIT
(
ii
,
index
,
INDEX
,
git_index_owner
(
index
));
if
((
error
=
iterator__update_ignore_case
((
git_iterator
*
)
ii
,
flags
))
<
0
)
{
if
((
error
=
iterator__update_ignore_case
((
git_iterator
*
)
ii
,
options
?
options
->
flags
:
0
))
<
0
)
{
git_iterator_free
((
git_iterator
*
)
ii
);
return
error
;
}
...
...
@@ -1062,6 +1059,8 @@ static int dirload_with_stat(
memcpy
(
ps
->
path
,
path
,
path_len
);
/* TODO: don't stat if assume unchanged for this path */
if
((
error
=
git_path_diriter_stat
(
&
ps
->
st
,
&
diriter
))
<
0
)
{
if
(
error
==
GIT_ENOTFOUND
)
{
/* file was removed between readdir and lstat */
...
...
@@ -1366,16 +1365,14 @@ static int fs_iterator__initialize(
int
git_iterator_for_filesystem
(
git_iterator
**
out
,
const
char
*
root
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
)
git_iterator_options
*
options
)
{
fs_iterator
*
fi
=
git__calloc
(
1
,
sizeof
(
fs_iterator
));
GITERR_CHECK_ALLOC
(
fi
);
ITERATOR_BASE_INIT
(
fi
,
fs
,
FS
,
NULL
);
if
(
(
flags
&
GIT_ITERATOR_IGNORE_CASE
)
!=
0
)
if
(
options
&&
(
options
->
flags
&
GIT_ITERATOR_IGNORE_CASE
)
!=
0
)
fi
->
base
.
flags
|=
GIT_ITERATOR_IGNORE_CASE
;
return
fs_iterator__initialize
(
out
,
fi
,
root
);
...
...
@@ -1559,9 +1556,7 @@ int git_iterator_for_workdir_ext(
const
char
*
repo_workdir
,
git_index
*
index
,
git_tree
*
tree
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
)
git_iterator_options
*
options
)
{
int
error
,
precompose
=
0
;
workdir_iterator
*
wi
;
...
...
@@ -1583,7 +1578,7 @@ int git_iterator_for_workdir_ext(
wi
->
fi
.
leave_dir_cb
=
workdir_iterator__leave_dir
;
wi
->
fi
.
update_entry_cb
=
workdir_iterator__update_entry
;
if
((
error
=
iterator__update_ignore_case
((
git_iterator
*
)
wi
,
flags
))
<
0
||
if
((
error
=
iterator__update_ignore_case
((
git_iterator
*
)
wi
,
options
?
options
->
flags
:
0
))
<
0
||
(
error
=
git_ignore__for_path
(
repo
,
".gitignore"
,
&
wi
->
ignores
))
<
0
)
{
git_iterator_free
((
git_iterator
*
)
wi
);
...
...
src/iterator.h
View file @
ed1c6446
...
...
@@ -38,6 +38,17 @@ typedef enum {
GIT_ITERATOR_INCLUDE_CONFLICTS
=
(
1u
<<
5
),
}
git_iterator_flag_t
;
typedef
struct
{
const
char
*
start
;
const
char
*
end
;
/* flags, from above */
unsigned
int
flags
;
}
git_iterator_options
;
#define GIT_ITERATOR_OPTIONS_INIT {0}
typedef
struct
{
int
(
*
current
)(
const
git_index_entry
**
,
git_iterator
*
);
int
(
*
advance
)(
const
git_index_entry
**
,
git_iterator
*
);
...
...
@@ -61,9 +72,7 @@ struct git_iterator {
extern
int
git_iterator_for_nothing
(
git_iterator
**
out
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
);
git_iterator_options
*
options
);
/* tree iterators will match the ignore_case value from the index of the
* repository, unless you override with a non-zero flag value
...
...
@@ -71,9 +80,7 @@ extern int git_iterator_for_nothing(
extern
int
git_iterator_for_tree
(
git_iterator
**
out
,
git_tree
*
tree
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
);
git_iterator_options
*
options
);
/* index iterators will take the ignore_case value from the index; the
* ignore_case flags are not used
...
...
@@ -81,9 +88,7 @@ extern int git_iterator_for_tree(
extern
int
git_iterator_for_index
(
git_iterator
**
out
,
git_index
*
index
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
);
git_iterator_options
*
options
);
extern
int
git_iterator_for_workdir_ext
(
git_iterator
**
out
,
...
...
@@ -91,9 +96,7 @@ extern int git_iterator_for_workdir_ext(
const
char
*
repo_workdir
,
git_index
*
index
,
git_tree
*
tree
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
);
git_iterator_options
*
options
);
/* workdir iterators will match the ignore_case value from the index of the
* repository, unless you override with a non-zero flag value
...
...
@@ -103,11 +106,9 @@ GIT_INLINE(int) git_iterator_for_workdir(
git_repository
*
repo
,
git_index
*
index
,
git_tree
*
tree
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
)
git_iterator_options
*
options
)
{
return
git_iterator_for_workdir_ext
(
out
,
repo
,
NULL
,
index
,
tree
,
flags
,
start
,
end
);
return
git_iterator_for_workdir_ext
(
out
,
repo
,
NULL
,
index
,
tree
,
options
);
}
/* for filesystem iterators, you have to explicitly pass in the ignore_case
...
...
@@ -116,9 +117,7 @@ GIT_INLINE(int) git_iterator_for_workdir(
extern
int
git_iterator_for_filesystem
(
git_iterator
**
out
,
const
char
*
root
,
git_iterator_flag_t
flags
,
const
char
*
start
,
const
char
*
end
);
git_iterator_options
*
options
);
extern
void
git_iterator_free
(
git_iterator
*
iter
);
...
...
src/merge.c
View file @
ed1c6446
...
...
@@ -1695,10 +1695,14 @@ on_error:
static
git_iterator
*
iterator_given_or_empty
(
git_iterator
**
empty
,
git_iterator
*
given
)
{
git_iterator_options
opts
=
GIT_ITERATOR_OPTIONS_INIT
;
if
(
given
)
return
given
;
if
(
git_iterator_for_nothing
(
empty
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
)
<
0
)
opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
if
(
git_iterator_for_nothing
(
empty
,
&
opts
)
<
0
)
return
NULL
;
return
*
empty
;
...
...
@@ -1780,14 +1784,17 @@ int git_merge_trees(
const
git_merge_options
*
merge_opts
)
{
git_iterator
*
ancestor_iter
=
NULL
,
*
our_iter
=
NULL
,
*
their_iter
=
NULL
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
int
error
;
if
((
error
=
git_iterator_for_tree
(
&
ancestor_iter
,
(
git_tree
*
)
ancestor_tree
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
our_iter
,
(
git_tree
*
)
our_tree
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
their_iter
,
(
git_tree
*
)
their_tree
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
)
iter_opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
if
((
error
=
git_iterator_for_tree
(
&
ancestor_iter
,
(
git_tree
*
)
ancestor_tree
,
&
iter_opts
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
our_iter
,
(
git_tree
*
)
our_tree
,
&
iter_opts
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
their_iter
,
(
git_tree
*
)
their_tree
,
&
iter_opts
))
<
0
)
goto
done
;
error
=
git_merge__iterators
(
...
...
@@ -2319,6 +2326,7 @@ static int merge_check_index(size_t *conflicts, git_repository *repo, git_index
git_tree
*
head_tree
=
NULL
;
git_index
*
index_repo
=
NULL
;
git_iterator
*
iter_repo
=
NULL
,
*
iter_new
=
NULL
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
git_diff
*
staged_diff_list
=
NULL
,
*
index_diff_list
=
NULL
;
git_diff_delta
*
delta
;
git_diff_options
opts
=
GIT_DIFF_OPTIONS_INIT
;
...
...
@@ -2351,8 +2359,10 @@ static int merge_check_index(size_t *conflicts, git_repository *repo, git_index
opts
.
pathspec
.
count
=
staged_paths
.
length
;
opts
.
pathspec
.
strings
=
(
char
**
)
staged_paths
.
contents
;
if
((
error
=
git_iterator_for_index
(
&
iter_repo
,
index_repo
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_index
(
&
iter_new
,
index_new
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
||
iter_opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
if
((
error
=
git_iterator_for_index
(
&
iter_repo
,
index_repo
,
&
iter_opts
))
<
0
||
(
error
=
git_iterator_for_index
(
&
iter_new
,
index_new
,
&
iter_opts
))
<
0
||
(
error
=
git_diff__from_iterators
(
&
index_diff_list
,
repo
,
iter_repo
,
iter_new
,
&
opts
))
<
0
)
goto
done
;
...
...
@@ -2414,6 +2424,7 @@ int git_merge__check_result(git_repository *repo, git_index *index_new)
{
git_tree
*
head_tree
=
NULL
;
git_iterator
*
iter_head
=
NULL
,
*
iter_new
=
NULL
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
git_diff
*
merged_list
=
NULL
;
git_diff_options
opts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff_delta
*
delta
;
...
...
@@ -2422,9 +2433,11 @@ int git_merge__check_result(git_repository *repo, git_index *index_new)
const
git_index_entry
*
e
;
int
error
=
0
;
iter_opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
if
((
error
=
git_repository_head_tree
(
&
head_tree
,
repo
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
iter_head
,
head_tree
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_index
(
&
iter_new
,
index_new
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
iter_head
,
head_tree
,
&
iter_opts
))
<
0
||
(
error
=
git_iterator_for_index
(
&
iter_new
,
index_new
,
&
iter_opts
))
<
0
||
(
error
=
git_diff__from_iterators
(
&
merged_list
,
repo
,
iter_head
,
iter_new
,
&
opts
))
<
0
)
goto
done
;
...
...
src/notes.c
View file @
ed1c6446
...
...
@@ -663,7 +663,7 @@ int git_note_iterator_new(
if
(
error
<
0
)
goto
cleanup
;
if
((
error
=
git_iterator_for_tree
(
it
,
tree
,
0
,
NULL
,
NULL
))
<
0
)
if
((
error
=
git_iterator_for_tree
(
it
,
tree
,
NULL
))
<
0
)
git_iterator_free
(
*
it
);
cleanup:
...
...
src/pathspec.c
View file @
ed1c6446
...
...
@@ -524,16 +524,16 @@ int git_pathspec_match_workdir(
uint32_t
flags
,
git_pathspec
*
ps
)
{
int
error
=
0
;
git_iterator
*
iter
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
int
error
=
0
;
assert
(
repo
);
if
(
!
(
error
=
git_iterator_for_workdir
(
&
iter
,
repo
,
NULL
,
NULL
,
pathspec_match_iter_flags
(
flags
),
NULL
,
NULL
)))
{
iter_opts
.
flags
=
pathspec_match_iter_flags
(
flags
);
if
(
!
(
error
=
git_iterator_for_workdir
(
&
iter
,
repo
,
NULL
,
NULL
,
&
iter_opts
)))
{
error
=
pathspec_match_from_iterator
(
out
,
iter
,
flags
,
ps
);
git_iterator_free
(
iter
);
}
...
...
@@ -546,16 +546,16 @@ int git_pathspec_match_index(
uint32_t
flags
,
git_pathspec
*
ps
)
{
int
error
=
0
;
git_iterator
*
iter
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
int
error
=
0
;
assert
(
index
);
if
(
!
(
error
=
git_iterator_for_index
(
&
iter
,
index
,
pathspec_match_iter_flags
(
flags
),
NULL
,
NULL
)))
{
iter_opts
.
flags
=
pathspec_match_iter_flags
(
flags
);
if
(
!
(
error
=
git_iterator_for_index
(
&
iter
,
index
,
&
iter_opts
)))
{
error
=
pathspec_match_from_iterator
(
out
,
iter
,
flags
,
ps
);
git_iterator_free
(
iter
);
}
...
...
@@ -568,16 +568,16 @@ int git_pathspec_match_tree(
uint32_t
flags
,
git_pathspec
*
ps
)
{
int
error
=
0
;
git_iterator
*
iter
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
int
error
=
0
;
assert
(
tree
);
if
(
!
(
error
=
git_iterator_for_tree
(
&
iter
,
tree
,
pathspec_match_iter_flags
(
flags
),
NULL
,
NULL
)))
{
iter_opts
.
flags
=
pathspec_match_iter_flags
(
flags
);
if
(
!
(
error
=
git_iterator_for_tree
(
&
iter
,
tree
,
&
iter_opts
)))
{
error
=
pathspec_match_from_iterator
(
out
,
iter
,
flags
,
ps
);
git_iterator_free
(
iter
);
}
...
...
src/refdb_fs.c
View file @
ed1c6446
...
...
@@ -480,14 +480,16 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
int
error
=
0
;
git_buf
path
=
GIT_BUF_INIT
;
git_iterator
*
fsit
=
NULL
;
git_iterator_options
fsit_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
=
NULL
;
if
(
!
backend
->
path
)
/* do nothing if no path for loose refs */
return
0
;
fsit_opts
.
flags
=
backend
->
iterator_flags
;
if
((
error
=
git_buf_printf
(
&
path
,
"%s/refs"
,
backend
->
path
))
<
0
||
(
error
=
git_iterator_for_filesystem
(
&
fsit
,
path
.
ptr
,
backend
->
iterator_flags
,
NULL
,
NULL
))
<
0
)
{
(
error
=
git_iterator_for_filesystem
(
&
fsit
,
path
.
ptr
,
&
fsit_opts
))
<
0
)
{
git_buf_free
(
&
path
);
return
error
;
}
...
...
src/stash.c
View file @
ed1c6446
...
...
@@ -679,12 +679,14 @@ static int merge_indexes(
git_index
*
theirs_index
)
{
git_iterator
*
ancestor
=
NULL
,
*
ours
=
NULL
,
*
theirs
=
NULL
;
const
git_iterator_flag_t
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
int
error
;
if
((
error
=
git_iterator_for_tree
(
&
ancestor
,
ancestor_tree
,
flags
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_index
(
&
ours
,
ours_index
,
flags
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_index
(
&
theirs
,
theirs_index
,
flags
,
NULL
,
NULL
))
<
0
)
iter_opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
if
((
error
=
git_iterator_for_tree
(
&
ancestor
,
ancestor_tree
,
&
iter_opts
))
<
0
||
(
error
=
git_iterator_for_index
(
&
ours
,
ours_index
,
&
iter_opts
))
<
0
||
(
error
=
git_iterator_for_index
(
&
theirs
,
theirs_index
,
&
iter_opts
))
<
0
)
goto
done
;
error
=
git_merge__iterators
(
out
,
repo
,
ancestor
,
ours
,
theirs
,
NULL
);
...
...
@@ -704,12 +706,14 @@ static int merge_index_and_tree(
git_tree
*
theirs_tree
)
{
git_iterator
*
ancestor
=
NULL
,
*
ours
=
NULL
,
*
theirs
=
NULL
;
const
git_iterator_flag_t
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
int
error
;
if
((
error
=
git_iterator_for_tree
(
&
ancestor
,
ancestor_tree
,
flags
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_index
(
&
ours
,
ours_index
,
flags
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
theirs
,
theirs_tree
,
flags
,
NULL
,
NULL
))
<
0
)
iter_opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
if
((
error
=
git_iterator_for_tree
(
&
ancestor
,
ancestor_tree
,
&
iter_opts
))
<
0
||
(
error
=
git_iterator_for_index
(
&
ours
,
ours_index
,
&
iter_opts
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
theirs
,
theirs_tree
,
&
iter_opts
))
<
0
)
goto
done
;
error
=
git_merge__iterators
(
out
,
repo
,
ancestor
,
ours
,
theirs
,
NULL
);
...
...
@@ -797,14 +801,15 @@ static int stage_new_files(
git_tree
*
tree
)
{
git_iterator
*
iterators
[
2
]
=
{
NULL
,
NULL
};
git_iterator_options
iterator_options
=
GIT_ITERATOR_OPTIONS_INIT
;
git_index
*
index
=
NULL
;
int
error
;
if
((
error
=
git_index_new
(
&
index
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
iterators
[
0
],
parent_tree
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
iterators
[
1
],
tree
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
))
<
0
)
(
error
=
git_iterator_for_tree
(
&
iterators
[
0
],
parent_tree
,
&
iterator_options
))
<
0
||
(
error
=
git_iterator_for_tree
(
&
iterators
[
1
],
tree
,
&
iterator_options
))
<
0
)
goto
done
;
error
=
git_iterator_walk
(
iterators
,
2
,
stage_new_file
,
index
);
...
...
src/submodule.c
View file @
ed1c6446
...
...
@@ -286,7 +286,7 @@ static int submodules_from_index(git_strmap *map, git_index *idx)
git_iterator
*
i
;
const
git_index_entry
*
entry
;
if
((
error
=
git_iterator_for_index
(
&
i
,
idx
,
0
,
NULL
,
NULL
))
<
0
)
if
((
error
=
git_iterator_for_index
(
&
i
,
idx
,
NULL
))
<
0
)
return
error
;
while
(
!
(
error
=
git_iterator_advance
(
&
entry
,
i
)))
{
...
...
@@ -322,7 +322,7 @@ static int submodules_from_head(git_strmap *map, git_tree *head)
git_iterator
*
i
;
const
git_index_entry
*
entry
;
if
((
error
=
git_iterator_for_tree
(
&
i
,
head
,
0
,
NULL
,
NULL
))
<
0
)
if
((
error
=
git_iterator_for_tree
(
&
i
,
head
,
NULL
))
<
0
)
return
error
;
while
(
!
(
error
=
git_iterator_advance
(
&
entry
,
i
)))
{
...
...
tests/diff/iterator.c
View file @
ed1c6446
...
...
@@ -30,13 +30,17 @@ static void tree_iterator_test(
{
git_tree
*
t
;
git_iterator
*
i
;
git_iterator_options
i_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
;
int
error
,
count
=
0
,
count_post_reset
=
0
;
git_repository
*
repo
=
cl_git_sandbox_init
(
sandbox
);
i_opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
i_opts
.
start
=
start
;
i_opts
.
end
=
end
;
cl_assert
(
t
=
resolve_commit_oid_to_tree
(
repo
,
treeish
));
cl_git_pass
(
git_iterator_for_tree
(
&
i
,
t
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
start
,
end
));
cl_git_pass
(
git_iterator_for_tree
(
&
i
,
t
,
&
i_opts
));
/* test loop */
while
(
!
(
error
=
git_iterator_advance
(
&
entry
,
i
)))
{
...
...
@@ -297,6 +301,7 @@ void test_diff_iterator__tree_special_functions(void)
{
git_tree
*
t
;
git_iterator
*
i
;
git_iterator_options
i_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
;
git_repository
*
repo
=
cl_git_sandbox_init
(
"attr"
);
int
error
,
cases
=
0
;
...
...
@@ -306,8 +311,9 @@ void test_diff_iterator__tree_special_functions(void)
repo
,
"24fa9a9fc4e202313e24b648087495441dab432b"
);
cl_assert
(
t
!=
NULL
);
cl_git_pass
(
git_iterator_for_tree
(
&
i
,
t
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
));
i_opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
cl_git_pass
(
git_iterator_for_tree
(
&
i
,
t
,
&
i_opts
));
while
(
!
(
error
=
git_iterator_advance
(
&
entry
,
i
)))
{
cl_assert
(
entry
);
...
...
@@ -365,11 +371,16 @@ static void index_iterator_test(
const
git_index_entry
*
entry
;
int
error
,
count
=
0
,
caps
;
git_repository
*
repo
=
cl_git_sandbox_init
(
sandbox
);
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
caps
=
git_index_caps
(
index
);
cl_git_pass
(
git_iterator_for_index
(
&
i
,
index
,
flags
,
start
,
end
));
iter_opts
.
flags
=
flags
;
iter_opts
.
start
=
start
;
iter_opts
.
end
=
end
;
cl_git_pass
(
git_iterator_for_index
(
&
i
,
index
,
&
iter_opts
));
while
(
!
(
error
=
git_iterator_advance
(
&
entry
,
i
)))
{
cl_assert
(
entry
);
...
...
@@ -581,12 +592,16 @@ static void workdir_iterator_test(
const
char
*
an_ignored_name
)
{
git_iterator
*
i
;
git_iterator_options
i_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
;
int
error
,
count
=
0
,
count_all
=
0
,
count_all_post_reset
=
0
;
git_repository
*
repo
=
cl_git_sandbox_init
(
sandbox
);
cl_git_pass
(
git_iterator_for_workdir
(
&
i
,
repo
,
NULL
,
NULL
,
GIT_ITERATOR_DONT_AUTOEXPAND
,
start
,
end
));
i_opts
.
flags
=
GIT_ITERATOR_DONT_AUTOEXPAND
;
i_opts
.
start
=
start
;
i_opts
.
end
=
end
;
cl_git_pass
(
git_iterator_for_workdir
(
&
i
,
repo
,
NULL
,
NULL
,
&
i_opts
));
error
=
git_iterator_current
(
&
entry
,
i
);
cl_assert
((
error
==
0
&&
entry
!=
NULL
)
||
...
...
@@ -765,6 +780,7 @@ void test_diff_iterator__workdir_builtin_ignores(void)
{
git_repository
*
repo
=
cl_git_sandbox_init
(
"attr"
);
git_iterator
*
i
;
git_iterator_options
i_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
;
int
idx
;
static
struct
{
...
...
@@ -796,8 +812,12 @@ void test_diff_iterator__workdir_builtin_ignores(void)
cl_git_pass
(
p_mkdir
(
"attr/sub/sub/.git"
,
0777
));
cl_git_mkfile
(
"attr/sub/.git"
,
"whatever"
);
i_opts
.
flags
=
GIT_ITERATOR_DONT_AUTOEXPAND
;
i_opts
.
start
=
"dir"
;
i_opts
.
end
=
"sub/sub/file"
;
cl_git_pass
(
git_iterator_for_workdir
(
&
i
,
repo
,
NULL
,
NULL
,
GIT_ITERATOR_DONT_AUTOEXPAND
,
"dir"
,
"sub/sub/file"
));
&
i
,
repo
,
NULL
,
NULL
,
&
i_opts
));
cl_git_pass
(
git_iterator_current
(
&
entry
,
i
));
for
(
idx
=
0
;
entry
!=
NULL
;
++
idx
)
{
...
...
@@ -827,12 +847,17 @@ static void check_wd_first_through_third_range(
git_repository
*
repo
,
const
char
*
start
,
const
char
*
end
)
{
git_iterator
*
i
;
git_iterator_options
i_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
;
int
error
,
idx
;
static
const
char
*
expected
[]
=
{
"FIRST"
,
"second"
,
"THIRD"
,
NULL
};
i_opts
.
flags
=
GIT_ITERATOR_IGNORE_CASE
;
i_opts
.
start
=
start
;
i_opts
.
end
=
end
;
cl_git_pass
(
git_iterator_for_workdir
(
&
i
,
repo
,
NULL
,
NULL
,
GIT_ITERATOR_IGNORE_CASE
,
start
,
end
));
&
i
,
repo
,
NULL
,
NULL
,
&
i_opts
));
cl_git_pass
(
git_iterator_current
(
&
entry
,
i
));
for
(
idx
=
0
;
entry
!=
NULL
;
++
idx
)
{
...
...
@@ -877,14 +902,16 @@ static void check_tree_range(
{
git_tree
*
head
;
git_iterator
*
i
;
git_iterator_options
i_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
int
error
,
count
;
i_opts
.
flags
=
ignore_case
?
GIT_ITERATOR_IGNORE_CASE
:
GIT_ITERATOR_DONT_IGNORE_CASE
;
i_opts
.
start
=
start
;
i_opts
.
end
=
end
;
cl_git_pass
(
git_repository_head_tree
(
&
head
,
repo
));
cl_git_pass
(
git_iterator_for_tree
(
&
i
,
head
,
ignore_case
?
GIT_ITERATOR_IGNORE_CASE
:
GIT_ITERATOR_DONT_IGNORE_CASE
,
start
,
end
));
cl_git_pass
(
git_iterator_for_tree
(
&
i
,
head
,
&
i_opts
));
for
(
count
=
0
;
!
(
error
=
git_iterator_advance
(
NULL
,
i
));
++
count
)
/* count em up */
;
...
...
@@ -931,6 +958,7 @@ static void check_index_range(
{
git_index
*
index
;
git_iterator
*
i
;
git_iterator_options
i_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
int
error
,
count
,
caps
;
bool
is_ignoring_case
;
...
...
@@ -942,7 +970,11 @@ static void check_index_range(
if
(
ignore_case
!=
is_ignoring_case
)
cl_git_pass
(
git_index_set_caps
(
index
,
caps
^
GIT_INDEXCAP_IGNORE_CASE
));
cl_git_pass
(
git_iterator_for_index
(
&
i
,
index
,
0
,
start
,
end
));
i_opts
.
flags
=
0
;
i_opts
.
start
=
start
;
i_opts
.
end
=
end
;
cl_git_pass
(
git_iterator_for_index
(
&
i
,
index
,
&
i_opts
));
cl_assert
(
git_iterator_ignore_case
(
i
)
==
ignore_case
);
...
...
tests/merge/trees/treediff.c
View file @
ed1c6446
...
...
@@ -44,6 +44,7 @@ static void test_find_differences(
git_oid
ancestor_oid
,
ours_oid
,
theirs_oid
;
git_tree
*
ancestor_tree
,
*
ours_tree
,
*
theirs_tree
;
git_iterator
*
ancestor_iter
,
*
ours_iter
,
*
theirs_iter
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
git_merge_options
opts
=
GIT_MERGE_OPTIONS_INIT
;
opts
.
tree_flags
|=
GIT_MERGE_TREE_FIND_RENAMES
;
...
...
@@ -67,12 +68,11 @@ static void test_find_differences(
cl_git_pass
(
git_tree_lookup
(
&
ours_tree
,
repo
,
&
ours_oid
));
cl_git_pass
(
git_tree_lookup
(
&
theirs_tree
,
repo
,
&
theirs_oid
));
cl_git_pass
(
git_iterator_for_tree
(
&
ancestor_iter
,
ancestor_tree
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
));
cl_git_pass
(
git_iterator_for_tree
(
&
ours_iter
,
ours_tree
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
));
cl_git_pass
(
git_iterator_for_tree
(
&
theirs_iter
,
theirs_tree
,
GIT_ITERATOR_DONT_IGNORE_CASE
,
NULL
,
NULL
));
iter_opts
.
flags
=
GIT_ITERATOR_DONT_IGNORE_CASE
;
cl_git_pass
(
git_iterator_for_tree
(
&
ancestor_iter
,
ancestor_tree
,
&
iter_opts
));
cl_git_pass
(
git_iterator_for_tree
(
&
ours_iter
,
ours_tree
,
&
iter_opts
));
cl_git_pass
(
git_iterator_for_tree
(
&
theirs_iter
,
theirs_tree
,
&
iter_opts
));
cl_git_pass
(
git_merge_diff_list__find_differences
(
merge_diff_list
,
ancestor_iter
,
ours_iter
,
theirs_iter
));
cl_git_pass
(
git_merge_diff_list__find_renames
(
repo
,
merge_diff_list
,
&
opts
));
...
...
tests/repo/iterator.c
View file @
ed1c6446
This diff is collapsed.
Click to expand it.
tests/submodule/status.c
View file @
ed1c6446
...
...
@@ -264,6 +264,7 @@ static int confirm_submodule_status(
void
test_submodule_status__iterator
(
void
)
{
git_iterator
*
iter
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
;
size_t
i
;
static
const
char
*
expected
[]
=
{
...
...
@@ -308,9 +309,10 @@ void test_submodule_status__iterator(void)
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
git_index
*
index
;
iter_opts
.
flags
=
GIT_ITERATOR_IGNORE_CASE
|
GIT_ITERATOR_INCLUDE_TREES
;
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_pass
(
git_iterator_for_workdir
(
&
iter
,
g_repo
,
index
,
NULL
,
GIT_ITERATOR_IGNORE_CASE
|
GIT_ITERATOR_INCLUDE_TREES
,
NULL
,
NULL
));
cl_git_pass
(
git_iterator_for_workdir
(
&
iter
,
g_repo
,
index
,
NULL
,
&
iter_opts
));
for
(
i
=
0
;
!
git_iterator_advance
(
&
entry
,
iter
);
++
i
)
cl_assert_equal_s
(
expected
[
i
],
entry
->
path
);
...
...
tests/threads/iterator.c
View file @
ed1c6446
...
...
@@ -13,10 +13,13 @@ static void *run_workdir_iterator(void *arg)
{
int
error
=
0
;
git_iterator
*
iter
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
=
NULL
;
iter_opts
.
flags
=
GIT_ITERATOR_DONT_AUTOEXPAND
;
cl_git_pass
(
git_iterator_for_workdir
(
&
iter
,
_repo
,
NULL
,
NULL
,
GIT_ITERATOR_DONT_AUTOEXPAND
,
NULL
,
NULL
));
&
iter
,
_repo
,
NULL
,
NULL
,
&
iter_opts
));
while
(
!
error
)
{
if
(
entry
&&
entry
->
mode
==
GIT_FILEMODE_TREE
)
{
...
...
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