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
f45d51ff
Commit
f45d51ff
authored
Nov 20, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API updates for index.h
parent
d9023dbe
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
63 additions
and
62 deletions
+63
-62
examples/general.c
+1
-1
include/git2/index.h
+39
-38
include/git2/tree.h
+1
-1
src/attr.c
+1
-1
src/index.c
+4
-4
src/iterator.c
+1
-1
src/submodule.c
+1
-1
src/tree.c
+4
-4
tests-clar/attr/repo.c
+1
-1
tests-clar/index/conflicts.c
+3
-3
tests-clar/index/filemodes.c
+2
-2
tests-clar/index/rename.c
+1
-1
tests-clar/index/stage.c
+2
-2
tests-clar/index/tests.c
+1
-1
tests-clar/object/commit/commitstagedfile.c
+1
-1
No files found.
examples/general.c
View file @
f45d51ff
...
...
@@ -371,7 +371,7 @@ int main (int argc, char** argv)
// All these properties are exported publicly in the `git_index_entry` struct
ecount
=
git_index_entrycount
(
index
);
for
(
i
=
0
;
i
<
ecount
;
++
i
)
{
git_index_entry
*
e
=
git_index_get_byindex
(
index
,
i
);
const
git_index_entry
*
e
=
git_index_get_byindex
(
index
,
i
);
printf
(
"path: %s
\n
"
,
e
->
path
);
printf
(
"mtime: %d
\n
"
,
(
int
)
e
->
mtime
.
seconds
);
...
...
include/git2/index.h
View file @
f45d51ff
...
...
@@ -21,10 +21,10 @@
*/
GIT_BEGIN_DECL
#define GIT_IDXENTRY_NAMEMASK (0x0fff)
#define GIT_IDXENTRY_NAMEMASK
(0x0fff)
#define GIT_IDXENTRY_STAGEMASK (0x3000)
#define GIT_IDXENTRY_EXTENDED (0x4000)
#define GIT_IDXENTRY_VALID
(0x8000)
#define GIT_IDXENTRY_EXTENDED
(0x4000)
#define GIT_IDXENTRY_VALID
(0x8000)
#define GIT_IDXENTRY_STAGESHIFT 12
/*
...
...
@@ -34,26 +34,26 @@ GIT_BEGIN_DECL
*
* In-memory only flags:
*/
#define GIT_IDXENTRY_UPDATE
(1 << 0)
#define GIT_IDXENTRY_REMOVE
(1 << 1)
#define GIT_IDXENTRY_UPTODATE
(1 << 2)
#define GIT_IDXENTRY_ADDED
(1 << 3)
#define GIT_IDXENTRY_UPDATE
(1 << 0)
#define GIT_IDXENTRY_REMOVE
(1 << 1)
#define GIT_IDXENTRY_UPTODATE
(1 << 2)
#define GIT_IDXENTRY_ADDED
(1 << 3)
#define GIT_IDXENTRY_HASHED
(1 << 4)
#define GIT_IDXENTRY_UNHASHED
(1 << 5)
#define GIT_IDXENTRY_WT_REMOVE
(1 << 6)
/* remove in work directory */
#define GIT_IDXENTRY_CONFLICTED
(1 << 7)
#define GIT_IDXENTRY_HASHED
(1 << 4)
#define GIT_IDXENTRY_UNHASHED
(1 << 5)
#define GIT_IDXENTRY_WT_REMOVE
(1 << 6)
/* remove in work directory */
#define GIT_IDXENTRY_CONFLICTED
(1 << 7)
#define GIT_IDXENTRY_UNPACKED
(1 << 8)
#define GIT_IDXENTRY_UNPACKED
(1 << 8)
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)
/*
* Extended on-disk flags:
*/
#define GIT_IDXENTRY_INTENT_TO_ADD
(1 << 13)
#define GIT_IDXENTRY_SKIP_WORKTREE
(1 << 14)
#define GIT_IDXENTRY_INTENT_TO_ADD
(1 << 13)
#define GIT_IDXENTRY_SKIP_WORKTREE
(1 << 14)
/* GIT_IDXENTRY_EXTENDED2 is for future extension */
#define GIT_IDXENTRY_EXTENDED2
(1 << 15)
#define GIT_IDXENTRY_EXTENDED2
(1 << 15)
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE)
...
...
@@ -119,11 +119,11 @@ enum {
*
* The index must be freed once it's no longer in use.
*
* @param
index
the pointer for the new index
* @param
out
the pointer for the new index
* @param index_path the path to the index file in disk
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_index_open
(
git_index
**
index
,
const
char
*
index_path
);
GIT_EXTERN
(
int
)
git_index_open
(
git_index
**
out
,
const
char
*
index_path
);
/**
* Create an in-memory index object.
...
...
@@ -133,10 +133,10 @@ GIT_EXTERN(int) git_index_open(git_index **index, const char *index_path);
*
* The index must be freed once it's no longer in use.
*
* @param
index
the pointer for the new index
* @param
out
the pointer for the new index
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_index_new
(
git_index
**
index
);
GIT_EXTERN
(
int
)
git_index_new
(
git_index
**
out
);
/**
* Free an existing index object.
...
...
@@ -201,7 +201,7 @@ GIT_EXTERN(int) git_index_write(git_index *index);
* @param tree tree to read
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_index_read_tree
(
git_index
*
index
,
git_tree
*
tree
);
GIT_EXTERN
(
int
)
git_index_read_tree
(
git_index
*
index
,
const
git_tree
*
tree
);
/**
* Write the index as a tree
...
...
@@ -217,12 +217,12 @@ GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree);
*
* The index must not contain any file in conflict.
*
* @param o
id
Pointer where to store the OID of the written tree
* @param o
ut
Pointer where to store the OID of the written tree
* @param index Index to write
* @return 0 on success, GIT_EUNMERGED when the index is not clean
* or an error code
*/
GIT_EXTERN
(
int
)
git_index_write_tree
(
git_oid
*
o
id
,
git_index
*
index
);
GIT_EXTERN
(
int
)
git_index_write_tree
(
git_oid
*
o
ut
,
git_index
*
index
);
/**
* Write the index as a tree to the given repository
...
...
@@ -233,13 +233,13 @@ GIT_EXTERN(int) git_index_write_tree(git_oid *oid, git_index *index);
*
* The index must not contain any file in conflict.
*
* @param o
id
Pointer where to store OID of the the written tree
* @param o
ut
Pointer where to store OID of the the written tree
* @param index Index to write
* @param repo Repository where to write the tree
* @return 0 on success, GIT_EUNMERGED when the index is not clean
* or an error code
*/
GIT_EXTERN
(
int
)
git_index_write_tree_to
(
git_oid
*
o
id
,
git_index
*
index
,
git_repository
*
repo
);
GIT_EXTERN
(
int
)
git_index_write_tree_to
(
git_oid
*
o
ut
,
git_index
*
index
,
git_repository
*
repo
);
/**@}*/
...
...
@@ -282,7 +282,7 @@ GIT_EXTERN(void) git_index_clear(git_index *index);
* @param n the position of the entry
* @return a pointer to the entry; NULL if out of bounds
*/
GIT_EXTERN
(
git_index_entry
*
)
git_index_get_byindex
(
git_index
*
index
,
size_t
n
);
GIT_EXTERN
(
const
git_index_entry
*
)
git_index_get_byindex
(
git_index
*
index
,
size_t
n
);
/**
* Get a pointer to one of the entries in the index
...
...
@@ -298,7 +298,7 @@ GIT_EXTERN(git_index_entry *) git_index_get_byindex(git_index *index, size_t n);
* @param stage stage to search
* @return a pointer to the entry; NULL if it was not found
*/
GIT_EXTERN
(
git_index_entry
*
)
git_index_get_bypath
(
git_index
*
index
,
const
char
*
path
,
int
stage
);
GIT_EXTERN
(
const
git_index_entry
*
)
git_index_get_bypath
(
git_index
*
index
,
const
char
*
path
,
int
stage
);
/**
* Remove an entry from the index
...
...
@@ -402,7 +402,8 @@ GIT_EXTERN(int) git_index_find(git_index *index, const char *path);
* @param their_entry the entry data for their side of the merge conflict
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_index_conflict_add
(
git_index
*
index
,
GIT_EXTERN
(
int
)
git_index_conflict_add
(
git_index
*
index
,
const
git_index_entry
*
ancestor_entry
,
const
git_index_entry
*
our_entry
,
const
git_index_entry
*
their_entry
);
...
...
@@ -475,7 +476,7 @@ GIT_EXTERN(int) git_index_reuc_find(git_index *index, const char *path);
* Get a resolve undo entry from the index.
*
* The returned entry is read-only and should not be modified
* o
f
freed by the caller.
* o
r
freed by the caller.
*
* @param index an existing index object
* @param path path to search
...
...
@@ -487,7 +488,7 @@ GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *in
* Get a resolve undo entry from the index.
*
* The returned entry is read-only and should not be modified
* o
f
freed by the caller.
* o
r
freed by the caller.
*
* @param index an existing index object
* @param n the position of the entry
...
...
@@ -496,7 +497,7 @@ GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_bypath(git_index *in
GIT_EXTERN
(
const
git_index_reuc_entry
*
)
git_index_reuc_get_byindex
(
git_index
*
index
,
size_t
n
);
/**
* Adds a
n
resolve undo entry for a file based on the given parameters.
* Adds a resolve undo entry for a file based on the given parameters.
*
* The resolve undo entry contains the OIDs of files that were involved
* in a merge conflict after the conflict has been resolved. This allows
...
...
@@ -510,26 +511,26 @@ GIT_EXTERN(const git_index_reuc_entry *) git_index_reuc_get_byindex(git_index *i
* @param index an existing index object
* @param path filename to add
* @param ancestor_mode mode of the ancestor file
* @param ancestor_
o
id oid of the ancestor file
* @param ancestor_id oid of the ancestor file
* @param our_mode mode of our file
* @param our_
o
id oid of our file
* @param our_id oid of our file
* @param their_mode mode of their file
* @param their_
o
id oid of their file
* @param their_id oid of their file
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_index_reuc_add
(
git_index
*
index
,
const
char
*
path
,
int
ancestor_mode
,
git_oid
*
ancestor_
o
id
,
int
our_mode
,
git_oid
*
our_
o
id
,
int
their_mode
,
git_oid
*
their_
o
id
);
int
ancestor_mode
,
git_oid
*
ancestor_id
,
int
our_mode
,
git_oid
*
our_id
,
int
their_mode
,
git_oid
*
their_id
);
/**
* Remove an resolve undo entry from the index
*
* @param index an existing index object
* @param
positio
n position of the resolve undo entry to remove
* @param n position of the resolve undo entry to remove
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_index_reuc_remove
(
git_index
*
index
,
int
positio
n
);
GIT_EXTERN
(
int
)
git_index_reuc_remove
(
git_index
*
index
,
size_t
n
);
/**@}*/
...
...
include/git2/tree.h
View file @
f45d51ff
...
...
@@ -371,7 +371,7 @@ typedef enum {
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_tree_walk
(
git_tree
*
tree
,
const
git_tree
*
tree
,
git_treewalk_mode
mode
,
git_treewalk_cb
callback
,
void
*
payload
);
...
...
src/attr.c
View file @
f45d51ff
...
...
@@ -295,7 +295,7 @@ static int load_attr_blob_from_index(
{
int
error
;
git_index
*
index
;
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
if
((
error
=
git_repository_index__weakptr
(
&
index
,
repo
))
<
0
||
(
error
=
git_index_find
(
index
,
relfile
))
<
0
)
...
...
src/index.c
View file @
f45d51ff
...
...
@@ -494,14 +494,14 @@ unsigned int git_index_entrycount(git_index *index)
return
(
unsigned
int
)
index
->
entries
.
length
;
}
git_index_entry
*
git_index_get_byindex
(
git_index
*
index
,
size_t
n
)
const
git_index_entry
*
git_index_get_byindex
(
git_index
*
index
,
size_t
n
)
{
assert
(
index
);
git_vector_sort
(
&
index
->
entries
);
return
git_vector_get
(
&
index
->
entries
,
n
);
}
git_index_entry
*
git_index_get_bypath
(
git_index
*
index
,
const
char
*
path
,
int
stage
)
const
git_index_entry
*
git_index_get_bypath
(
git_index
*
index
,
const
char
*
path
,
int
stage
)
{
int
pos
;
...
...
@@ -1072,7 +1072,7 @@ const git_index_reuc_entry *git_index_reuc_get_byindex(
return
git_vector_get
(
&
index
->
reuc
,
n
);
}
int
git_index_reuc_remove
(
git_index
*
index
,
in
t
position
)
int
git_index_reuc_remove
(
git_index
*
index
,
size_
t
position
)
{
int
error
;
git_index_reuc_entry
*
reuc
;
...
...
@@ -1599,7 +1599,7 @@ static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *da
return
0
;
}
int
git_index_read_tree
(
git_index
*
index
,
git_tree
*
tree
)
int
git_index_read_tree
(
git_index
*
index
,
const
git_tree
*
tree
)
{
git_index_clear
(
index
);
...
...
src/iterator.c
View file @
f45d51ff
...
...
@@ -337,7 +337,7 @@ static int index_iterator__current(
git_iterator
*
self
,
const
git_index_entry
**
entry
)
{
index_iterator
*
ii
=
(
index_iterator
*
)
self
;
git_index_entry
*
ie
=
git_index_get_byindex
(
ii
->
index
,
ii
->
current
);
const
git_index_entry
*
ie
=
git_index_get_byindex
(
ii
->
index
,
ii
->
current
);
if
(
ie
!=
NULL
&&
ii
->
base
.
end
!=
NULL
&&
...
...
src/submodule.c
View file @
f45d51ff
...
...
@@ -733,7 +733,7 @@ int git_submodule_reload(git_submodule *submodule)
pos
=
git_index_find
(
index
,
submodule
->
path
);
if
(
pos
>=
0
)
{
git_index_entry
*
entry
=
git_index_get_byindex
(
index
,
pos
);
const
git_index_entry
*
entry
=
git_index_get_byindex
(
index
,
pos
);
if
(
S_ISGITLINK
(
entry
->
mode
))
{
if
((
error
=
submodule_load_from_index
(
repo
,
entry
))
<
0
)
...
...
src/tree.c
View file @
f45d51ff
...
...
@@ -356,7 +356,7 @@ static unsigned int find_next_dir(const char *dirname, git_index *index, unsigne
dirlen
=
strlen
(
dirname
);
for
(
i
=
start
;
i
<
entries
;
++
i
)
{
git_index_entry
*
entry
=
git_index_get_byindex
(
index
,
i
);
const
git_index_entry
*
entry
=
git_index_get_byindex
(
index
,
i
);
if
(
strlen
(
entry
->
path
)
<
dirlen
||
memcmp
(
entry
->
path
,
dirname
,
dirlen
)
||
(
dirlen
>
0
&&
entry
->
path
[
dirlen
]
!=
'/'
))
{
...
...
@@ -421,7 +421,7 @@ static int write_tree(
* need to keep track of the current position.
*/
for
(
i
=
start
;
i
<
entries
;
++
i
)
{
git_index_entry
*
entry
=
git_index_get_byindex
(
index
,
i
);
const
git_index_entry
*
entry
=
git_index_get_byindex
(
index
,
i
);
char
*
filename
,
*
next_slash
;
/*
...
...
@@ -807,7 +807,7 @@ int git_tree_entry_bypath(
}
static
int
tree_walk
(
git_tree
*
tree
,
const
git_tree
*
tree
,
git_treewalk_cb
callback
,
git_buf
*
path
,
void
*
payload
,
...
...
@@ -860,7 +860,7 @@ static int tree_walk(
}
int
git_tree_walk
(
git_tree
*
tree
,
const
git_tree
*
tree
,
git_treewalk_mode
mode
,
git_treewalk_cb
callback
,
void
*
payload
)
...
...
tests-clar/attr/repo.c
View file @
f45d51ff
...
...
@@ -267,7 +267,7 @@ static void add_to_workdir(const char *filename, const char *content)
static
void
assert_proper_normalization
(
git_index
*
index
,
const
char
*
filename
,
const
char
*
expected_sha
)
{
int
index_pos
;
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
add_to_workdir
(
filename
,
CONTENT
);
cl_git_pass
(
git_index_add_from_workdir
(
index
,
filename
));
...
...
tests-clar/index/conflicts.c
View file @
f45d51ff
...
...
@@ -132,7 +132,7 @@ void test_index_conflicts__get(void)
void
test_index_conflicts__remove
(
void
)
{
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
size_t
i
;
cl_assert
(
git_index_entrycount
(
repo_index
)
==
8
);
...
...
@@ -156,7 +156,7 @@ void test_index_conflicts__remove(void)
void
test_index_conflicts__moved_to_reuc
(
void
)
{
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
size_t
i
;
cl_assert
(
git_index_entrycount
(
repo_index
)
==
8
);
...
...
@@ -178,7 +178,7 @@ void test_index_conflicts__moved_to_reuc(void)
void
test_index_conflicts__remove_all_conflicts
(
void
)
{
size_t
i
;
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
cl_assert
(
git_index_entrycount
(
repo_index
)
==
8
);
...
...
tests-clar/index/filemodes.c
View file @
f45d51ff
...
...
@@ -25,7 +25,7 @@ void test_index_filemodes__read(void)
cl_assert_equal_i
(
6
,
git_index_entrycount
(
index
));
for
(
i
=
0
;
i
<
6
;
++
i
)
{
git_index_entry
*
entry
=
git_index_get_byindex
(
index
,
i
);
const
git_index_entry
*
entry
=
git_index_get_byindex
(
index
,
i
);
cl_assert
(
entry
!=
NULL
);
cl_assert
(((
entry
->
mode
&
0100
)
?
1
:
0
)
==
expected
[
i
]);
}
...
...
@@ -54,7 +54,7 @@ static void add_and_check_mode(
git_index
*
index
,
const
char
*
filename
,
unsigned
int
expect_mode
)
{
int
pos
;
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
cl_git_pass
(
git_index_add_from_workdir
(
index
,
filename
));
...
...
tests-clar/index/rename.c
View file @
f45d51ff
...
...
@@ -7,7 +7,7 @@ void test_index_rename__single_file(void)
git_index
*
index
;
int
position
;
git_oid
expected
;
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
p_mkdir
(
"rename"
,
0700
);
...
...
tests-clar/index/stage.c
View file @
f45d51ff
...
...
@@ -27,7 +27,7 @@ void test_index_stage__cleanup(void)
void
test_index_stage__add_always_adds_stage_0
(
void
)
{
int
entry_idx
;
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
cl_git_mkfile
(
"./mergedrepo/new-file.txt"
,
"new-file
\n
"
);
...
...
@@ -41,7 +41,7 @@ void test_index_stage__add_always_adds_stage_0(void)
void
test_index_stage__find_gets_first_stage
(
void
)
{
int
entry_idx
;
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
cl_assert
((
entry_idx
=
git_index_find
(
repo_index
,
"one.txt"
))
>=
0
);
cl_assert
((
entry
=
git_index_get_byindex
(
repo_index
,
entry_idx
))
!=
NULL
);
...
...
tests-clar/index/tests.c
View file @
f45d51ff
...
...
@@ -208,7 +208,7 @@ void test_index_tests__add(void)
git_index
*
index
;
git_filebuf
file
=
GIT_FILEBUF_INIT
;
git_repository
*
repo
;
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
git_oid
id1
;
/* Intialize a new repository */
...
...
tests-clar/object/commit/commitstagedfile.c
View file @
f45d51ff
...
...
@@ -21,7 +21,7 @@ void test_object_commit_commitstagedfile__cleanup(void)
void
test_object_commit_commitstagedfile__generate_predictable_object_ids
(
void
)
{
git_index
*
index
;
git_index_entry
*
entry
;
const
git_index_entry
*
entry
;
git_oid
expected_blob_oid
,
tree_oid
,
expected_tree_oid
,
commit_oid
,
expected_commit_oid
;
git_signature
*
signature
;
git_tree
*
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