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
9d0011fd
Commit
9d0011fd
authored
May 16, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree: Naming conventions
parent
eb270884
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
14 deletions
+17
-14
include/git2/tree.h
+1
-1
src/index.c
+1
-1
src/iterator.c
+4
-4
src/tree.c
+8
-5
src/tree.h
+2
-2
tests-clar/object/tree/read.c
+1
-1
No files found.
include/git2/tree.h
View file @
9d0011fd
...
@@ -143,7 +143,7 @@ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
...
@@ -143,7 +143,7 @@ GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
* @param entry a tree entry
* @param entry a tree entry
* @return GIT_SUCCESS or an error code
* @return GIT_SUCCESS or an error code
*/
*/
GIT_EXTERN
(
int
)
git_tree_entry_
2
object
(
git_object
**
object_out
,
git_repository
*
repo
,
const
git_tree_entry
*
entry
);
GIT_EXTERN
(
int
)
git_tree_entry_
to_
object
(
git_object
**
object_out
,
git_repository
*
repo
,
const
git_tree_entry
*
entry
);
/**
/**
* Write a tree to the ODB from the index file
* Write a tree to the ODB from the index file
...
...
src/index.c
View file @
9d0011fd
...
@@ -939,7 +939,7 @@ static int read_tree_cb(const char *root, git_tree_entry *tentry, void *data)
...
@@ -939,7 +939,7 @@ static int read_tree_cb(const char *root, git_tree_entry *tentry, void *data)
git_index_entry
*
entry
=
NULL
;
git_index_entry
*
entry
=
NULL
;
git_buf
path
=
GIT_BUF_INIT
;
git_buf
path
=
GIT_BUF_INIT
;
if
(
entry
_is_tree
(
tentry
))
if
(
git_tree_entry_
_is_tree
(
tentry
))
return
0
;
return
0
;
if
(
git_buf_joinpath
(
&
path
,
root
,
tentry
->
filename
)
<
0
)
if
(
git_buf_joinpath
(
&
path
,
root
,
tentry
->
filename
)
<
0
)
...
...
src/iterator.c
View file @
9d0011fd
...
@@ -178,7 +178,7 @@ static tree_iterator_frame *tree_iterator__alloc_frame(
...
@@ -178,7 +178,7 @@ static tree_iterator_frame *tree_iterator__alloc_frame(
if
(
start
&&
*
start
)
{
if
(
start
&&
*
start
)
{
tf
->
start
=
start
;
tf
->
start
=
start
;
tf
->
index
=
git_tree_
entry
_prefix_position
(
tree
,
start
);
tf
->
index
=
git_tree__prefix_position
(
tree
,
start
);
}
}
return
tf
;
return
tf
;
...
@@ -192,7 +192,7 @@ static int tree_iterator__expand_tree(tree_iterator *ti)
...
@@ -192,7 +192,7 @@ static int tree_iterator__expand_tree(tree_iterator *ti)
tree_iterator_frame
*
tf
;
tree_iterator_frame
*
tf
;
char
*
relpath
;
char
*
relpath
;
while
(
te
!=
NULL
&&
entry
_is_tree
(
te
))
{
while
(
te
!=
NULL
&&
git_tree_entry_
_is_tree
(
te
))
{
if
(
git_buf_joinpath
(
&
ti
->
path
,
ti
->
path
.
ptr
,
te
->
filename
)
<
0
)
if
(
git_buf_joinpath
(
&
ti
->
path
,
ti
->
path
.
ptr
,
te
->
filename
)
<
0
)
return
-
1
;
return
-
1
;
...
@@ -252,7 +252,7 @@ static int tree_iterator__advance(
...
@@ -252,7 +252,7 @@ static int tree_iterator__advance(
git_buf_rtruncate_at_char
(
&
ti
->
path
,
'/'
);
git_buf_rtruncate_at_char
(
&
ti
->
path
,
'/'
);
}
}
if
(
te
&&
entry
_is_tree
(
te
))
if
(
te
&&
git_tree_entry_
_is_tree
(
te
))
error
=
tree_iterator__expand_tree
(
ti
);
error
=
tree_iterator__expand_tree
(
ti
);
if
(
!
error
)
if
(
!
error
)
...
@@ -288,7 +288,7 @@ static int tree_iterator__reset(git_iterator *self)
...
@@ -288,7 +288,7 @@ static int tree_iterator__reset(git_iterator *self)
if
(
ti
->
stack
)
if
(
ti
->
stack
)
ti
->
stack
->
index
=
ti
->
stack
->
index
=
git_tree_
entry
_prefix_position
(
ti
->
stack
->
tree
,
ti
->
base
.
start
);
git_tree__prefix_position
(
ti
->
stack
->
tree
,
ti
->
base
.
start
);
git_buf_clear
(
&
ti
->
path
);
git_buf_clear
(
&
ti
->
path
);
...
...
src/tree.c
View file @
9d0011fd
...
@@ -31,8 +31,8 @@ static int entry_sort_cmp(const void *a, const void *b)
...
@@ -31,8 +31,8 @@ static int entry_sort_cmp(const void *a, const void *b)
const
git_tree_entry
*
entry_b
=
(
const
git_tree_entry
*
)(
b
);
const
git_tree_entry
*
entry_b
=
(
const
git_tree_entry
*
)(
b
);
return
git_path_cmp
(
return
git_path_cmp
(
entry_a
->
filename
,
entry_a
->
filename_len
,
entry
_is_tree
(
entry_a
),
entry_a
->
filename
,
entry_a
->
filename_len
,
git_tree_entry_
_is_tree
(
entry_a
),
entry_b
->
filename
,
entry_b
->
filename_len
,
entry
_is_tree
(
entry_b
));
entry_b
->
filename
,
entry_b
->
filename_len
,
git_tree_entry_
_is_tree
(
entry_b
));
}
}
...
@@ -170,7 +170,10 @@ git_otype git_tree_entry_type(const git_tree_entry *entry)
...
@@ -170,7 +170,10 @@ git_otype git_tree_entry_type(const git_tree_entry *entry)
return
GIT_OBJ_BLOB
;
return
GIT_OBJ_BLOB
;
}
}
int
git_tree_entry_2object
(
git_object
**
object_out
,
git_repository
*
repo
,
const
git_tree_entry
*
entry
)
int
git_tree_entry_to_object
(
git_object
**
object_out
,
git_repository
*
repo
,
const
git_tree_entry
*
entry
)
{
{
assert
(
entry
&&
object_out
);
assert
(
entry
&&
object_out
);
return
git_object_lookup
(
object_out
,
repo
,
&
entry
->
oid
,
GIT_OBJ_ANY
);
return
git_object_lookup
(
object_out
,
repo
,
&
entry
->
oid
,
GIT_OBJ_ANY
);
...
@@ -195,7 +198,7 @@ const git_tree_entry *git_tree_entry_byindex(git_tree *tree, unsigned int idx)
...
@@ -195,7 +198,7 @@ const git_tree_entry *git_tree_entry_byindex(git_tree *tree, unsigned int idx)
return
git_vector_get
(
&
tree
->
entries
,
idx
);
return
git_vector_get
(
&
tree
->
entries
,
idx
);
}
}
int
git_tree_
entry
_prefix_position
(
git_tree
*
tree
,
const
char
*
path
)
int
git_tree__prefix_position
(
git_tree
*
tree
,
const
char
*
path
)
{
{
git_vector
*
entries
=
&
tree
->
entries
;
git_vector
*
entries
=
&
tree
->
entries
;
struct
tree_key_search
ksearch
;
struct
tree_key_search
ksearch
;
...
@@ -730,7 +733,7 @@ static int tree_walk_post(
...
@@ -730,7 +733,7 @@ static int tree_walk_post(
if
(
callback
(
path
->
ptr
,
entry
,
payload
)
<
0
)
if
(
callback
(
path
->
ptr
,
entry
,
payload
)
<
0
)
continue
;
continue
;
if
(
entry
_is_tree
(
entry
))
{
if
(
git_tree_entry_
_is_tree
(
entry
))
{
git_tree
*
subtree
;
git_tree
*
subtree
;
size_t
path_len
=
git_buf_len
(
path
);
size_t
path_len
=
git_buf_len
(
path
);
...
...
src/tree.h
View file @
9d0011fd
...
@@ -30,7 +30,7 @@ struct git_treebuilder {
...
@@ -30,7 +30,7 @@ struct git_treebuilder {
};
};
GIT_INLINE
(
unsigned
int
)
entry
_is_tree
(
const
struct
git_tree_entry
*
e
)
GIT_INLINE
(
bool
)
git_tree_entry_
_is_tree
(
const
struct
git_tree_entry
*
e
)
{
{
return
(
S_ISDIR
(
e
->
attr
)
&&
!
S_ISGITLINK
(
e
->
attr
));
return
(
S_ISDIR
(
e
->
attr
)
&&
!
S_ISGITLINK
(
e
->
attr
));
}
}
...
@@ -45,7 +45,7 @@ int git_tree__parse(git_tree *tree, git_odb_object *obj);
...
@@ -45,7 +45,7 @@ int git_tree__parse(git_tree *tree, git_odb_object *obj);
* @param prefix the beginning of a path to find in the tree.
* @param prefix the beginning of a path to find in the tree.
* @return index of the first item at or after the given prefix.
* @return index of the first item at or after the given prefix.
*/
*/
int
git_tree_
entry
_prefix_position
(
git_tree
*
tree
,
const
char
*
prefix
);
int
git_tree__prefix_position
(
git_tree
*
tree
,
const
char
*
prefix
);
#endif
#endif
tests-clar/object/tree/read.c
View file @
9d0011fd
...
@@ -67,7 +67,7 @@ void test_object_tree_read__two(void)
...
@@ -67,7 +67,7 @@ void test_object_tree_read__two(void)
cl_assert_equal_s
(
git_tree_entry_name
(
entry
),
"README"
);
cl_assert_equal_s
(
git_tree_entry_name
(
entry
),
"README"
);
cl_git_pass
(
git_tree_entry_
2
object
(
&
obj
,
g_repo
,
entry
));
cl_git_pass
(
git_tree_entry_
to_
object
(
&
obj
,
g_repo
,
entry
));
cl_assert
(
obj
!=
NULL
);
cl_assert
(
obj
!=
NULL
);
git_object_free
(
obj
);
git_object_free
(
obj
);
...
...
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