summaryrefslogtreecommitdiff
path: root/src/git/index.h
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-11-02 18:42:42 +0200
committerVicent Marti <tanoku@gmail.com>2010-11-02 18:42:42 +0200
commit6fd195d76c7f52baae5540e287affe2259900d36 (patch)
tree4dd644c5086dce17827f42b8c811049175da88f9 /src/git/index.h
parentd80e9d55aa2d0629f7f207db42762494075d7854 (diff)
downloadlibgit2-6fd195d76c7f52baae5540e287affe2259900d36.tar.gz
Change git_repository initialization to use a path
The constructor to git_repository is now called 'git_repository_open(path)' and takes a path to a git repository instead of an existing ODB object. Unit tests have been updated accordingly and the two test repositories have been merged into one. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/git/index.h')
-rw-r--r--src/git/index.h50
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