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
5d1f31c6
Commit
5d1f31c6
authored
Dec 03, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3530 from libgit2/cmn/parse-mode
tree: use a specialised mode parse function
parents
2d36e145
0174f21b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
src/tree.c
+21
-5
No files found.
src/tree.c
View file @
5d1f31c6
...
...
@@ -416,6 +416,25 @@ static int tree_error(const char *str, const char *path)
return
-
1
;
}
static
int
parse_mode
(
unsigned
int
*
modep
,
const
char
*
buffer
,
const
char
**
buffer_out
)
{
unsigned
char
c
;
unsigned
int
mode
=
0
;
if
(
*
buffer
==
' '
)
return
-
1
;
while
((
c
=
*
buffer
++
)
!=
' '
)
{
if
(
c
<
'0'
||
c
>
'7'
)
return
-
1
;
mode
=
(
mode
<<
3
)
+
(
c
-
'0'
);
}
*
modep
=
mode
;
*
buffer_out
=
buffer
;
return
0
;
}
int
git_tree__parse
(
void
*
_tree
,
git_odb_object
*
odb_obj
)
{
git_tree
*
tree
=
_tree
;
...
...
@@ -430,14 +449,11 @@ int git_tree__parse(void *_tree, git_odb_object *odb_obj)
git_tree_entry
*
entry
;
size_t
filename_len
;
const
char
*
nul
;
int
attr
;
unsigned
int
attr
;
if
(
git__strtol32
(
&
attr
,
buffer
,
&
buffer
,
8
)
<
0
||
!
buffer
)
if
(
parse_mode
(
&
attr
,
buffer
,
&
buffer
)
<
0
||
!
buffer
)
return
tree_error
(
"Failed to parse tree. Can't parse filemode"
,
NULL
);
if
(
*
buffer
++
!=
' '
)
return
tree_error
(
"Failed to parse tree. Object is corrupted"
,
NULL
);
if
((
nul
=
memchr
(
buffer
,
0
,
buffer_end
-
buffer
))
==
NULL
)
return
tree_error
(
"Failed to parse tree. Object is corrupted"
,
NULL
);
...
...
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