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
b6011e29
Commit
b6011e29
authored
Jun 07, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3185 from libgit2/cmn/foreach-cancel-loose
path: error out if the callback returns an error
parents
fdb82dcd
8da44047
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
src/path.c
+4
-2
tests/odb/foreach.c
+20
-0
No files found.
src/path.c
View file @
b6011e29
...
...
@@ -1066,8 +1066,10 @@ int git_path_direach(
git_buf_truncate
(
path
,
wd_len
);
/* restore path */
/* Only set our own error if the callback did not set one already */
if
(
error
!=
0
&&
!
giterr_last
())
{
giterr_set_after_callback
(
error
);
if
(
error
!=
0
)
{
if
(
!
giterr_last
())
giterr_set_after_callback
(
error
);
break
;
}
}
...
...
tests/odb/foreach.c
View file @
b6011e29
...
...
@@ -71,15 +71,35 @@ static int foreach_stop_cb(const git_oid *oid, void *data)
return
(
*
nobj
==
1000
)
?
-
321
:
0
;
}
static
int
foreach_stop_first_cb
(
const
git_oid
*
oid
,
void
*
data
)
{
int
*
nobj
=
data
;
(
*
nobj
)
++
;
GIT_UNUSED
(
oid
);
return
-
123
;
}
void
test_odb_foreach__interrupt_foreach
(
void
)
{
int
nobj
=
0
;
git_oid
id
;
cl_git_pass
(
git_repository_open
(
&
_repo
,
cl_fixture
(
"testrepo.git"
)));
git_repository_odb
(
&
_odb
,
_repo
);
cl_assert_equal_i
(
-
321
,
git_odb_foreach
(
_odb
,
foreach_stop_cb
,
&
nobj
));
cl_assert
(
nobj
==
1000
);
git_odb_free
(
_odb
);
git_repository_free
(
_repo
);
cl_git_pass
(
git_repository_init
(
&
_repo
,
"onlyloose.git"
,
true
));
git_repository_odb
(
&
_odb
,
_repo
);
cl_git_pass
(
git_odb_write
(
&
id
,
_odb
,
""
,
0
,
GIT_OBJ_BLOB
));
cl_assert_equal_i
(
-
123
,
git_odb_foreach
(
_odb
,
foreach_stop_first_cb
,
&
nobj
));
}
void
test_odb_foreach__files_in_objects_dir
(
void
)
...
...
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