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
75e051c6
Commit
75e051c6
authored
Jan 27, 2011
by
John Wiegley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added git_tree_add_entry_unsorted and git_tree_sort_entries
parent
2f8a8ab2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
5 deletions
+48
-5
src/git2/tree.h
+30
-0
src/tree.c
+18
-5
No files found.
src/git2/tree.h
View file @
75e051c6
...
...
@@ -149,6 +149,36 @@ GIT_EXTERN(int) git_tree_entry_2object(git_object **object, git_tree_entry *entr
GIT_EXTERN
(
int
)
git_tree_add_entry
(
git_tree_entry
**
entry_out
,
git_tree
*
tree
,
const
git_oid
*
id
,
const
char
*
filename
,
int
attributes
);
/**
* Add a new entry to a tree, returning that new entry.
* The only difference with this call is that it does not sort
* tree afterwards, this requirement is left to the caller.
*
* This will mark the tree as modified; the new entry will
* be written back to disk on the next git_object_write()
*
* @param entry Entry object which will be created
* @param tree Tree object to store the entry
* @iparam id OID for the tree entry
* @param filename Filename for the tree entry
* @param attributes UNIX file attributes for the entry
* @return 0 on success; otherwise error code
*/
GIT_EXTERN
(
int
)
git_tree_add_entry_unsorted
(
git_tree_entry
**
entry
,
git_tree
*
tree
,
const
git_oid
*
id
,
const
char
*
filename
,
int
attributes
);
/**
* Sort the entries in a tree created using git_tree_add_entry2.
*
* This does not mark the tree as modified. It is intended to be used
* after several invocations of git_tree_add_entry2.
* git_tree_add_entry, on the other hand, sorts after each entry is
* added.
*
* @param tree Tree object whose entries are to be sorted
* @return 0 on success; otherwise error code
*/
GIT_EXTERN
(
int
)
git_tree_sort_entries
(
git_tree
*
tree
);
/**
* Remove an entry by its index.
*
* Index must be >= 0 and < than git_tree_entrycount().
...
...
src/tree.c
View file @
75e051c6
...
...
@@ -174,12 +174,11 @@ size_t git_tree_entrycount(git_tree *tree)
return
tree
->
entries
.
length
;
}
int
git_tree_add_entry
(
git_tree_entry
**
entry_out
,
git_tree
*
tree
,
const
git_oid
*
id
,
const
char
*
filename
,
int
attributes
)
int
git_tree_add_entry
_unsorted
(
git_tree_entry
**
entry_out
,
git_tree
*
tree
,
const
git_oid
*
id
,
const
char
*
filename
,
int
attributes
)
{
git_tree_entry
*
entry
;
assert
(
tree
&&
id
&&
filename
);
git_tree_entry
*
entry
;
if
((
entry
=
git__malloc
(
sizeof
(
git_tree_entry
)))
==
NULL
)
return
GIT_ENOMEM
;
...
...
@@ -193,8 +192,6 @@ int git_tree_add_entry(git_tree_entry **entry_out, git_tree *tree, const git_oid
if
(
git_vector_insert
(
&
tree
->
entries
,
entry
)
<
0
)
return
GIT_ENOMEM
;
git_vector_sort
(
&
tree
->
entries
);
if
(
entry_out
!=
NULL
)
*
entry_out
=
entry
;
...
...
@@ -202,6 +199,22 @@ int git_tree_add_entry(git_tree_entry **entry_out, git_tree *tree, const git_oid
return
GIT_SUCCESS
;
}
int
git_tree_add_entry
(
git_tree_entry
**
entry_out
,
git_tree
*
tree
,
const
git_oid
*
id
,
const
char
*
filename
,
int
attributes
)
{
int
result
=
git_tree_add_entry_unsorted
(
entry_out
,
tree
,
id
,
filename
,
attributes
);
if
(
result
==
GIT_SUCCESS
)
{
git_vector_sort
(
&
tree
->
entries
);
return
GIT_SUCCESS
;
}
return
result
;
}
int
git_tree_sort_entries
(
git_tree
*
tree
)
{
git_vector_sort
(
&
tree
->
entries
);
return
GIT_SUCCESS
;
}
int
git_tree_remove_entry_byindex
(
git_tree
*
tree
,
int
idx
)
{
git_tree_entry
*
remove_ptr
;
...
...
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