mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-09 22:27:57 +00:00
Index: API uniformisation: Use unsigned int for all index number.
Feature Added: Search an unmerged entry by path (git_index_get_unmerged renamed to git_index_get_unmerged_bypath) or by index (git_index_get_unmerged_byindex).
This commit is contained in:
parent
e5c8009731
commit
f11e079733
@ -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);
|
|||||||
* @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
|
||||||
|
12
src/index.c
12
src/index.c
@ -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)
|
|||||||
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
|
|||||||
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user