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
ca27ae48
Commit
ca27ae48
authored
Oct 08, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1894 from libgit2/cmn/tree-raw
tree: allow retrieval of raw attributes
parents
711333ef
13f670a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
include/git2/tree.h
+11
-0
src/tree.c
+6
-3
tests-clar/object/tree/attributes.c
+2
-1
No files found.
include/git2/tree.h
View file @
ca27ae48
...
...
@@ -199,6 +199,17 @@ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
GIT_EXTERN
(
git_filemode_t
)
git_tree_entry_filemode
(
const
git_tree_entry
*
entry
);
/**
* Get the raw UNIX file attributes of a tree entry
*
* This function does not perform any normalization and is only useful
* if you need to be able to recreate the original tree object.
*
* @param entry a tree entry
* @return filemode as an integer
*/
GIT_EXTERN
(
git_filemode_t
)
git_tree_entry_filemode_raw
(
const
git_tree_entry
*
entry
);
/**
* Compare two tree entries
*
* @param e1 first tree entry
...
...
src/tree.c
View file @
ca27ae48
...
...
@@ -237,7 +237,12 @@ void git_tree__free(void *_tree)
git_filemode_t
git_tree_entry_filemode
(
const
git_tree_entry
*
entry
)
{
return
(
git_filemode_t
)
entry
->
attr
;
return
normalize_filemode
(
entry
->
attr
);
}
git_filemode_t
git_tree_entry_filemode_raw
(
const
git_tree_entry
*
entry
)
{
return
entry
->
attr
;
}
const
char
*
git_tree_entry_name
(
const
git_tree_entry
*
entry
)
...
...
@@ -386,8 +391,6 @@ int git_tree__parse(void *_tree, git_odb_object *odb_obj)
if
(
git__strtol32
(
&
attr
,
buffer
,
&
buffer
,
8
)
<
0
||
!
buffer
)
return
tree_error
(
"Failed to parse tree. Can't parse filemode"
,
NULL
);
attr
=
normalize_filemode
(
attr
);
/* make sure to normalize the filemode */
if
(
*
buffer
++
!=
' '
)
return
tree_error
(
"Failed to parse tree. Object is corrupted"
,
NULL
);
...
...
tests-clar/object/tree/attributes.c
View file @
ca27ae48
...
...
@@ -107,7 +107,8 @@ void test_object_tree_attributes__normalize_600(void)
cl_git_pass
(
git_tree_lookup
(
&
tree
,
repo
,
&
id
));
entry
=
git_tree_entry_byname
(
tree
,
"ListaTeste.xml"
);
cl_assert_equal_i
(
entry
->
attr
,
GIT_FILEMODE_BLOB
);
cl_assert_equal_i
(
git_tree_entry_filemode
(
entry
),
GIT_FILEMODE_BLOB
);
cl_assert_equal_i
(
git_tree_entry_filemode_raw
(
entry
),
0100600
);
git_tree_free
(
tree
);
cl_git_sandbox_cleanup
();
...
...
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