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
00c31dd2
Commit
00c31dd2
authored
Jun 06, 2011
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #234 from Romain-Geissler/entry-count-API-uniformisation
[Tree | Index] API uniformisation
parents
2c9e7fa3
c5d8745f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
14 deletions
+32
-14
include/git2/index.h
+14
-2
include/git2/tree.h
+2
-2
src/index.c
+9
-3
src/tree.c
+7
-7
No files found.
include/git2/index.h
View file @
00c31dd2
...
@@ -257,7 +257,7 @@ GIT_EXTERN(int) git_index_remove(git_index *index, int position);
...
@@ -257,7 +257,7 @@ GIT_EXTERN(int) git_index_remove(git_index *index, int position);
* @param n the position of the entry
* @param n the position of the entry
* @return a pointer to the entry; NULL if out of bounds
* @return a pointer to the entry; NULL if out of bounds
*/
*/
GIT_EXTERN
(
git_index_entry
*
)
git_index_get
(
git_index
*
index
,
int
n
);
GIT_EXTERN
(
git_index_entry
*
)
git_index_get
(
git_index
*
index
,
unsigned
int
n
);
/**
/**
* Get the count of entries currently in the index
* Get the count of entries currently in the index
...
@@ -285,7 +285,19 @@ GIT_EXTERN(unsigned int) git_index_entrycount_unmerged(git_index *index);
...
@@ -285,7 +285,19 @@ GIT_EXTERN(unsigned int) git_index_entrycount_unmerged(git_index *index);
* @param path path to search
* @param path path to search
* @return the unmerged entry; NULL if not found
* @return the unmerged entry; NULL if not found
*/
*/
GIT_EXTERN
(
const
git_index_entry_unmerged
*
)
git_index_get_unmerged
(
git_index
*
index
,
const
char
*
path
);
GIT_EXTERN
(
const
git_index_entry_unmerged
*
)
git_index_get_unmerged_bypath
(
git_index
*
index
,
const
char
*
path
);
/**
* Get an unmerged entry from the index.
*
* The returned entry is read-only and should not be modified
* of freed by the caller.
*
* @param index an existing index object
* @param n the position of the entry
* @return a pointer to the unmerged entry; NULL if out of bounds
*/
GIT_EXTERN
(
const
git_index_entry_unmerged
*
)
git_index_get_unmerged_byindex
(
git_index
*
index
,
unsigned
int
n
);
/**
/**
* Return the stage number from a git index entry
* Return the stage number from a git index entry
...
...
include/git2/tree.h
View file @
00c31dd2
...
@@ -84,7 +84,7 @@ GIT_EXTERN(const git_oid *) git_tree_id(git_tree *tree);
...
@@ -84,7 +84,7 @@ GIT_EXTERN(const git_oid *) git_tree_id(git_tree *tree);
* @param tree a previously loaded tree.
* @param tree a previously loaded tree.
* @return the number of entries in the tree
* @return the number of entries in the tree
*/
*/
GIT_EXTERN
(
size_
t
)
git_tree_entrycount
(
git_tree
*
tree
);
GIT_EXTERN
(
unsigned
in
t
)
git_tree_entrycount
(
git_tree
*
tree
);
/**
/**
* Lookup a tree entry by its filename
* Lookup a tree entry by its filename
...
@@ -102,7 +102,7 @@ GIT_EXTERN(const git_tree_entry *) git_tree_entry_byname(git_tree *tree, const c
...
@@ -102,7 +102,7 @@ GIT_EXTERN(const git_tree_entry *) git_tree_entry_byname(git_tree *tree, const c
* @param idx the position in the entry list
* @param idx the position in the entry list
* @return the tree entry; NULL if not found
* @return the tree entry; NULL if not found
*/
*/
GIT_EXTERN
(
const
git_tree_entry
*
)
git_tree_entry_byindex
(
git_tree
*
tree
,
int
idx
);
GIT_EXTERN
(
const
git_tree_entry
*
)
git_tree_entry_byindex
(
git_tree
*
tree
,
unsigned
int
idx
);
/**
/**
* Get the UNIX file attributes of a tree entry
* Get the UNIX file attributes of a tree entry
...
...
src/index.c
View file @
00c31dd2
...
@@ -322,11 +322,11 @@ unsigned int git_index_entrycount_unmerged(git_index *index)
...
@@ -322,11 +322,11 @@ unsigned int git_index_entrycount_unmerged(git_index *index)
return
index
->
unmerged
.
length
;
return
index
->
unmerged
.
length
;
}
}
git_index_entry
*
git_index_get
(
git_index
*
index
,
int
n
)
git_index_entry
*
git_index_get
(
git_index
*
index
,
unsigned
int
n
)
{
{
assert
(
index
);
assert
(
index
);
sort_index
(
index
);
sort_index
(
index
);
return
git_vector_get
(
&
index
->
entries
,
(
unsigned
int
)
n
);
return
git_vector_get
(
&
index
->
entries
,
n
);
}
}
static
void
sort_index
(
git_index
*
index
)
static
void
sort_index
(
git_index
*
index
)
...
@@ -479,7 +479,7 @@ int git_index_find(git_index *index, const char *path)
...
@@ -479,7 +479,7 @@ int git_index_find(git_index *index, const char *path)
return
git_vector_bsearch2
(
&
index
->
entries
,
index_srch
,
path
);
return
git_vector_bsearch2
(
&
index
->
entries
,
index_srch
,
path
);
}
}
const
git_index_entry_unmerged
*
git_index_get_unmerged
(
git_index
*
index
,
const
char
*
path
)
const
git_index_entry_unmerged
*
git_index_get_unmerged
_bypath
(
git_index
*
index
,
const
char
*
path
)
{
{
int
pos
;
int
pos
;
assert
(
index
&&
path
);
assert
(
index
&&
path
);
...
@@ -493,6 +493,12 @@ const git_index_entry_unmerged *git_index_get_unmerged(git_index *index, const c
...
@@ -493,6 +493,12 @@ const git_index_entry_unmerged *git_index_get_unmerged(git_index *index, const c
return
git_vector_get
(
&
index
->
unmerged
,
pos
);
return
git_vector_get
(
&
index
->
unmerged
,
pos
);
}
}
const
git_index_entry_unmerged
*
git_index_get_unmerged_byindex
(
git_index
*
index
,
unsigned
int
n
)
{
assert
(
index
);
return
git_vector_get
(
&
index
->
unmerged
,
n
);
}
static
int
read_tree_internal
(
git_index_tree
**
out
,
static
int
read_tree_internal
(
git_index_tree
**
out
,
const
char
**
buffer_in
,
const
char
*
buffer_end
,
git_index_tree
*
parent
)
const
char
**
buffer_in
,
const
char
*
buffer_end
,
git_index_tree
*
parent
)
...
...
src/tree.c
View file @
00c31dd2
...
@@ -119,13 +119,13 @@ const git_tree_entry *git_tree_entry_byname(git_tree *tree, const char *filename
...
@@ -119,13 +119,13 @@ const git_tree_entry *git_tree_entry_byname(git_tree *tree, const char *filename
return
git_vector_get
(
&
tree
->
entries
,
idx
);
return
git_vector_get
(
&
tree
->
entries
,
idx
);
}
}
const
git_tree_entry
*
git_tree_entry_byindex
(
git_tree
*
tree
,
int
idx
)
const
git_tree_entry
*
git_tree_entry_byindex
(
git_tree
*
tree
,
unsigned
int
idx
)
{
{
assert
(
tree
);
assert
(
tree
);
return
git_vector_get
(
&
tree
->
entries
,
(
unsigned
int
)
idx
);
return
git_vector_get
(
&
tree
->
entries
,
idx
);
}
}
size_
t
git_tree_entrycount
(
git_tree
*
tree
)
unsigned
in
t
git_tree_entrycount
(
git_tree
*
tree
)
{
{
assert
(
tree
);
assert
(
tree
);
return
tree
->
entries
.
length
;
return
tree
->
entries
.
length
;
...
@@ -288,7 +288,7 @@ static void sort_entries(git_treebuilder *bld)
...
@@ -288,7 +288,7 @@ static void sort_entries(git_treebuilder *bld)
int
git_treebuilder_create
(
git_treebuilder
**
builder_p
,
const
git_tree
*
source
)
int
git_treebuilder_create
(
git_treebuilder
**
builder_p
,
const
git_tree
*
source
)
{
{
git_treebuilder
*
bld
;
git_treebuilder
*
bld
;
size_
t
i
,
source_entries
=
DEFAULT_TREE_SIZE
;
unsigned
in
t
i
,
source_entries
=
DEFAULT_TREE_SIZE
;
assert
(
builder_p
);
assert
(
builder_p
);
...
@@ -409,7 +409,7 @@ int git_treebuilder_remove(git_treebuilder *bld, const char *filename)
...
@@ -409,7 +409,7 @@ int git_treebuilder_remove(git_treebuilder *bld, const char *filename)
int
git_treebuilder_write
(
git_oid
*
oid
,
git_repository
*
repo
,
git_treebuilder
*
bld
)
int
git_treebuilder_write
(
git_oid
*
oid
,
git_repository
*
repo
,
git_treebuilder
*
bld
)
{
{
size_
t
i
,
size
=
0
;
unsigned
in
t
i
,
size
=
0
;
char
filemode
[
MAX_FILEMODE_BYTES
+
1
+
1
];
char
filemode
[
MAX_FILEMODE_BYTES
+
1
+
1
];
git_odb_stream
*
stream
;
git_odb_stream
*
stream
;
int
error
;
int
error
;
...
@@ -453,7 +453,7 @@ int git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *b
...
@@ -453,7 +453,7 @@ int git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *b
void
git_treebuilder_filter
(
git_treebuilder
*
bld
,
int
(
*
filter
)(
const
git_tree_entry
*
,
void
*
),
void
*
payload
)
void
git_treebuilder_filter
(
git_treebuilder
*
bld
,
int
(
*
filter
)(
const
git_tree_entry
*
,
void
*
),
void
*
payload
)
{
{
size_
t
i
;
unsigned
in
t
i
;
assert
(
bld
&&
filter
);
assert
(
bld
&&
filter
);
...
@@ -466,7 +466,7 @@ void git_treebuilder_filter(git_treebuilder *bld, int (*filter)(const git_tree_e
...
@@ -466,7 +466,7 @@ void git_treebuilder_filter(git_treebuilder *bld, int (*filter)(const git_tree_e
void
git_treebuilder_clear
(
git_treebuilder
*
bld
)
void
git_treebuilder_clear
(
git_treebuilder
*
bld
)
{
{
size_
t
i
;
unsigned
in
t
i
;
assert
(
bld
);
assert
(
bld
);
for
(
i
=
0
;
i
<
bld
->
entries
.
length
;
++
i
)
{
for
(
i
=
0
;
i
<
bld
->
entries
.
length
;
++
i
)
{
...
...
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