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
45d387ac
Commit
45d387ac
authored
Feb 15, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refs: Error handling rework. WIP
parent
60bc2d20
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
11 deletions
+19
-11
include/git2/errors.h
+3
-0
src/path.c
+16
-11
src/refs.c
+0
-0
No files found.
include/git2/errors.h
View file @
45d387ac
...
...
@@ -122,9 +122,12 @@ typedef struct {
typedef
enum
{
GITERR_NOMEMORY
,
GITERR_REFERENCE
,
}
git_error_class
;
#define GITERR_CHECK_ALLOC(ptr, error) if (ptr == NULL) { giterr_set_oom(error); return -1 }
GIT_EXTERN
(
void
)
giterr_set
(
git_error
**
error_out
,
int
error_class
,
const
char
*
string
,
...);
GIT_EXTERN
(
void
)
giterr_set_oom
(
git_error
**
error
);
GIT_EXTERN
(
void
)
giterr_free
(
git_error
*
error
);
...
...
src/path.c
View file @
45d387ac
...
...
@@ -486,20 +486,23 @@ GIT_INLINE(int) is_dot_or_dotdot(const char *name)
int
git_path_direach
(
git_buf
*
path
,
int
(
*
fn
)(
void
*
,
git_buf
*
),
void
*
arg
)
int
(
*
fn
)(
void
*
,
git_buf
*
,
git_error
**
),
void
*
arg
,
git_error
**
error
)
{
ssize_t
wd_len
;
DIR
*
dir
;
struct
dirent
de_buf
,
*
de
;
if
(
git_path_to_dir
(
path
)
<
GIT_SUCCESS
)
return
git_buf_lasterror
(
path
)
;
if
(
git_path_to_dir
(
path
,
error
)
<
0
)
return
-
1
;
wd_len
=
path
->
size
;
dir
=
opendir
(
path
->
ptr
);
if
(
!
dir
)
return
git__throw
(
GIT_EOSERR
,
"Failed to process `%s` tree structure. An error occured while opening the directory"
,
path
->
ptr
);
if
(
!
dir
)
{
giterr_set
(
error
,
GITERR_OS
,
"Failed to `opendir` %s: %s"
,
path
->
ptr
,
strerror
(
errno
));
return
-
1
;
}
while
(
p_readdir_r
(
dir
,
&
de_buf
,
&
de
)
==
0
&&
de
!=
NULL
)
{
int
result
;
...
...
@@ -507,16 +510,18 @@ int git_path_direach(
if
(
is_dot_or_dotdot
(
de
->
d_name
))
continue
;
if
(
git_buf_puts
(
path
,
de
->
d_name
)
<
GIT_SUCCESS
)
return
git_buf_lasterror
(
path
);
if
(
git_buf_puts
(
path
,
de
->
d_name
)
<
0
)
{
giterr_set_oom
(
error
);
return
-
1
;
}
result
=
fn
(
arg
,
path
);
result
=
fn
(
arg
,
path
,
error
);
git_buf_truncate
(
path
,
wd_len
);
/* restore path */
if
(
result
!=
GIT_SUCCESS
)
{
if
(
result
<
0
)
{
closedir
(
dir
);
return
result
;
/* The callee is reponsible for setting the correct error message */
return
-
1
;
}
}
...
...
src/refs.c
View file @
45d387ac
This diff is collapsed.
Click to expand it.
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