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
e120123e
Commit
e120123e
authored
Nov 20, 2012
by
Russell Belfer
Committed by
Ben Straub
Nov 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API review / update for tree.h
parent
824cb2d5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
17 deletions
+25
-17
examples/general.c
+2
-2
include/git2/tree.h
+0
-0
src/index.c
+1
-1
src/iterator.c
+1
-1
src/notes.c
+2
-2
src/pack-objects.c
+1
-1
src/tree.c
+12
-4
tests-clar/object/tree/walk.c
+6
-6
No files found.
examples/general.c
View file @
e120123e
...
@@ -261,8 +261,8 @@ int main (int argc, char** argv)
...
@@ -261,8 +261,8 @@ int main (int argc, char** argv)
git_tree_lookup
(
&
tree
,
repo
,
&
oid
);
git_tree_lookup
(
&
tree
,
repo
,
&
oid
);
// Getting the count of entries in the tree so you can iterate over them if you want to.
// Getting the count of entries in the tree so you can iterate over them if you want to.
in
t
cnt
=
git_tree_entrycount
(
tree
);
// 3
size_
t
cnt
=
git_tree_entrycount
(
tree
);
// 3
printf
(
"tree entries: %d
\n
"
,
cnt
);
printf
(
"tree entries: %d
\n
"
,
(
int
)
cnt
);
entry
=
git_tree_entry_byindex
(
tree
,
0
);
entry
=
git_tree_entry_byindex
(
tree
,
0
);
printf
(
"Entry name: %s
\n
"
,
git_tree_entry_name
(
entry
));
// "hello.c"
printf
(
"Entry name: %s
\n
"
,
git_tree_entry_name
(
entry
));
// "hello.c"
...
...
include/git2/tree.h
View file @
e120123e
This diff is collapsed.
Click to expand it.
src/index.c
View file @
e120123e
...
@@ -1603,7 +1603,7 @@ int git_index_read_tree(git_index *index, git_tree *tree)
...
@@ -1603,7 +1603,7 @@ int git_index_read_tree(git_index *index, git_tree *tree)
{
{
git_index_clear
(
index
);
git_index_clear
(
index
);
return
git_tree_walk
(
tree
,
read_tree_cb
,
GIT_TREEWALK_POST
,
index
);
return
git_tree_walk
(
tree
,
GIT_TREEWALK_POST
,
read_tree_cb
,
index
);
}
}
git_repository
*
git_index_owner
(
const
git_index
*
index
)
git_repository
*
git_index_owner
(
const
git_index
*
index
)
...
...
src/iterator.c
View file @
e120123e
...
@@ -85,7 +85,7 @@ struct tree_iterator_frame {
...
@@ -85,7 +85,7 @@ struct tree_iterator_frame {
tree_iterator_frame
*
next
,
*
prev
;
tree_iterator_frame
*
next
,
*
prev
;
git_tree
*
tree
;
git_tree
*
tree
;
char
*
start
;
char
*
start
;
unsigned
in
t
index
;
size_
t
index
;
};
};
typedef
struct
{
typedef
struct
{
...
...
src/notes.c
View file @
e120123e
...
@@ -19,7 +19,7 @@ static int find_subtree_in_current_level(
...
@@ -19,7 +19,7 @@ static int find_subtree_in_current_level(
const
char
*
annotated_object_sha
,
const
char
*
annotated_object_sha
,
int
fanout
)
int
fanout
)
{
{
unsigned
in
t
i
;
size_
t
i
;
const
git_tree_entry
*
entry
;
const
git_tree_entry
*
entry
;
*
out
=
NULL
;
*
out
=
NULL
;
...
@@ -71,7 +71,7 @@ static int find_subtree_r(git_tree **out, git_tree *root,
...
@@ -71,7 +71,7 @@ static int find_subtree_r(git_tree **out, git_tree *root,
static
int
find_blob
(
git_oid
*
blob
,
git_tree
*
tree
,
const
char
*
target
)
static
int
find_blob
(
git_oid
*
blob
,
git_tree
*
tree
,
const
char
*
target
)
{
{
unsigned
in
t
i
;
size_
t
i
;
const
git_tree_entry
*
entry
;
const
git_tree_entry
*
entry
;
for
(
i
=
0
;
i
<
git_tree_entrycount
(
tree
);
i
++
)
{
for
(
i
=
0
;
i
<
git_tree_entrycount
(
tree
);
i
++
)
{
...
...
src/pack-objects.c
View file @
e120123e
...
@@ -1284,7 +1284,7 @@ int git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid)
...
@@ -1284,7 +1284,7 @@ int git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid)
git_packbuilder_insert
(
pb
,
oid
,
NULL
)
<
0
)
git_packbuilder_insert
(
pb
,
oid
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
if
(
git_tree_walk
(
tree
,
cb_tree_walk
,
GIT_TREEWALK_PRE
,
pb
)
<
0
)
{
if
(
git_tree_walk
(
tree
,
GIT_TREEWALK_PRE
,
cb_tree_walk
,
pb
)
<
0
)
{
git_tree_free
(
tree
);
git_tree_free
(
tree
);
return
-
1
;
return
-
1
;
}
}
...
...
src/tree.c
View file @
e120123e
...
@@ -166,6 +166,7 @@ git_tree_entry *git_tree_entry_dup(const git_tree_entry *entry)
...
@@ -166,6 +166,7 @@ git_tree_entry *git_tree_entry_dup(const git_tree_entry *entry)
return
NULL
;
return
NULL
;
memcpy
(
copy
,
entry
,
total_size
);
memcpy
(
copy
,
entry
,
total_size
);
return
copy
;
return
copy
;
}
}
...
@@ -288,10 +289,10 @@ int git_tree__prefix_position(git_tree *tree, const char *path)
...
@@ -288,10 +289,10 @@ int git_tree__prefix_position(git_tree *tree, const char *path)
return
at_pos
;
return
at_pos
;
}
}
unsigned
in
t
git_tree_entrycount
(
const
git_tree
*
tree
)
size_
t
git_tree_entrycount
(
const
git_tree
*
tree
)
{
{
assert
(
tree
);
assert
(
tree
);
return
(
unsigned
int
)
tree
->
entries
.
length
;
return
tree
->
entries
.
length
;
}
}
static
int
tree_error
(
const
char
*
str
)
static
int
tree_error
(
const
char
*
str
)
...
@@ -694,7 +695,10 @@ on_error:
...
@@ -694,7 +695,10 @@ on_error:
return
-
1
;
return
-
1
;
}
}
void
git_treebuilder_filter
(
git_treebuilder
*
bld
,
int
(
*
filter
)(
const
git_tree_entry
*
,
void
*
),
void
*
payload
)
void
git_treebuilder_filter
(
git_treebuilder
*
bld
,
git_treebuilder_filter_cb
filter
,
void
*
payload
)
{
{
unsigned
int
i
;
unsigned
int
i
;
...
@@ -855,7 +859,11 @@ static int tree_walk(
...
@@ -855,7 +859,11 @@ static int tree_walk(
return
error
;
return
error
;
}
}
int
git_tree_walk
(
git_tree
*
tree
,
git_treewalk_cb
callback
,
int
mode
,
void
*
payload
)
int
git_tree_walk
(
git_tree
*
tree
,
git_treewalk_mode
mode
,
git_treewalk_cb
callback
,
void
*
payload
)
{
{
int
error
=
0
;
int
error
=
0
;
git_buf
root_path
=
GIT_BUF_INIT
;
git_buf
root_path
=
GIT_BUF_INIT
;
...
...
tests-clar/object/tree/walk.c
View file @
e120123e
...
@@ -38,11 +38,11 @@ void test_object_tree_walk__0(void)
...
@@ -38,11 +38,11 @@ void test_object_tree_walk__0(void)
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
id
));
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
id
));
ct
=
0
;
ct
=
0
;
cl_git_pass
(
git_tree_walk
(
tree
,
treewalk_count_cb
,
GIT_TREEWALK_PRE
,
&
ct
));
cl_git_pass
(
git_tree_walk
(
tree
,
GIT_TREEWALK_PRE
,
treewalk_count_cb
,
&
ct
));
cl_assert_equal_i
(
3
,
ct
);
cl_assert_equal_i
(
3
,
ct
);
ct
=
0
;
ct
=
0
;
cl_git_pass
(
git_tree_walk
(
tree
,
treewalk_count_cb
,
GIT_TREEWALK_POST
,
&
ct
));
cl_git_pass
(
git_tree_walk
(
tree
,
GIT_TREEWALK_POST
,
treewalk_count_cb
,
&
ct
));
cl_assert_equal_i
(
3
,
ct
);
cl_assert_equal_i
(
3
,
ct
);
git_tree_free
(
tree
);
git_tree_free
(
tree
);
...
@@ -83,21 +83,21 @@ void test_object_tree_walk__1(void)
...
@@ -83,21 +83,21 @@ void test_object_tree_walk__1(void)
ct
=
0
;
ct
=
0
;
cl_assert_equal_i
(
cl_assert_equal_i
(
GIT_EUSER
,
git_tree_walk
(
tree
,
treewalk_stop_cb
,
GIT_TREEWALK_PRE
,
&
ct
));
GIT_EUSER
,
git_tree_walk
(
tree
,
GIT_TREEWALK_PRE
,
treewalk_stop_cb
,
&
ct
));
cl_assert_equal_i
(
2
,
ct
);
cl_assert_equal_i
(
2
,
ct
);
ct
=
0
;
ct
=
0
;
cl_assert_equal_i
(
cl_assert_equal_i
(
GIT_EUSER
,
git_tree_walk
(
tree
,
treewalk_stop_cb
,
GIT_TREEWALK_POST
,
&
ct
));
GIT_EUSER
,
git_tree_walk
(
tree
,
GIT_TREEWALK_POST
,
treewalk_stop_cb
,
&
ct
));
cl_assert_equal_i
(
2
,
ct
);
cl_assert_equal_i
(
2
,
ct
);
cl_assert_equal_i
(
cl_assert_equal_i
(
GIT_EUSER
,
git_tree_walk
(
GIT_EUSER
,
git_tree_walk
(
tree
,
treewalk_stop_immediately_cb
,
GIT_TREEWALK_PRE
,
NULL
));
tree
,
GIT_TREEWALK_PRE
,
treewalk_stop_immediately_cb
,
NULL
));
cl_assert_equal_i
(
cl_assert_equal_i
(
GIT_EUSER
,
git_tree_walk
(
GIT_EUSER
,
git_tree_walk
(
tree
,
treewalk_stop_immediately_cb
,
GIT_TREEWALK_POST
,
NULL
));
tree
,
GIT_TREEWALK_POST
,
treewalk_stop_immediately_cb
,
NULL
));
git_tree_free
(
tree
);
git_tree_free
(
tree
);
}
}
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