diff options
Diffstat (limited to 'src/git/index.h')
-rw-r--r-- | src/git/index.h | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/src/git/index.h b/src/git/index.h index 46fccbd74..3b262355e 100644 --- a/src/git/index.h +++ b/src/git/index.h @@ -1,6 +1,7 @@ #ifndef INCLUDE_git_index_h__ #define INCLUDE_git_index_h__ +#include <stdint.h> #include "common.h" #include "oid.h" @@ -16,18 +17,50 @@ GIT_BEGIN_DECL /** Memory representation of an index file. */ typedef struct git_index git_index; + +/** Time used in a git index entry */ +typedef struct { + uint32_t seconds; + uint32_t nanoseconds; +} git_index_time; + /** Memory representation of a file entry in the index. */ -typedef struct git_index_entry git_index_entry; +typedef struct git_index_entry { + git_index_time ctime; + git_index_time mtime; + + uint32_t dev; + uint32_t ino; + uint32_t mode; + uint32_t uid; + uint32_t gid; + uint32_t file_size; + + git_oid oid; + + uint16_t flags; + uint16_t flags_extended; + + char *path; +} git_index_entry; /** * Create a new Git index object as a memory representation * of the Git index file in 'index_path'. * + * The argument 'working_dir' is the root path of the indexed + * files in the index and is used to calculate the relative path + * when inserting new entries from existing files on disk. + * + * If 'working _dir' is NULL (e.g for bare repositories), the + * methods working on on-disk files will fail. + * * @param index_path the path to the index file in disk + * @param working_dir working dir for the git repository * @return the index object; NULL if the index could not be created */ -GIT_EXTERN(git_index *) git_index_alloc(const char *index_path); +GIT_EXTERN(git_index *) git_index_alloc(const char *index_path, const char *working_dir); /** * Clear the contents (all the entries) of an index object. @@ -83,6 +116,19 @@ GIT_EXTERN(int) git_index_find(git_index *index, const char *path); */ GIT_EXTERN(int) git_index_add(git_index *index, const char *path, int stage); +/** + * Get a pointer to one of the entries in the index + * + * This entry can be modified, and the changes will be written + * back to disk on the next write() call. + * + * @param index an existing index object + * @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(git_index *index, int n); + + /** @} */ GIT_END_DECL #endif |