summaryrefslogtreecommitdiff
path: root/include/git2/index.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-06-19 14:27:02 -0700
committerRussell Belfer <rb@github.com>2012-06-19 14:27:02 -0700
commitda825c92d92433240ceeaea70d7618395bcfb83d (patch)
tree1cdf8d9c08d101d0ebc40b7e07eb4ba1c41611b2 /include/git2/index.h
parent1b0ef5aa03fad68105784d5d4d87592ce005e03a (diff)
downloadlibgit2-da825c92d92433240ceeaea70d7618395bcfb83d.tar.gz
Make index add/append support core.filemode flag
This fixes git_index_add and git_index_append to behave more like core git, preserving old filemode data in the index when adding and/or appending with core.filemode = false. This also has placeholder support for core.symlinks and core.ignorecase, but those flags are not implemented (well, symlinks has partial support for preserving mode information in the same way that git does, but it isn't tested).
Diffstat (limited to 'include/git2/index.h')
-rw-r--r--include/git2/index.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/git2/index.h b/include/git2/index.h
index 0fb0f955..b8897ea9 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -90,6 +90,14 @@ typedef struct git_index_entry_unmerged {
char *path;
} git_index_entry_unmerged;
+/** Capabilities of system that affect index actions. */
+enum {
+ GIT_INDEXCAP_IGNORE_CASE = 1,
+ GIT_INDEXCAP_NO_FILEMODE = 2,
+ GIT_INDEXCAP_NO_SYMLINKS = 4,
+ GIT_INDEXCAP_FROM_OWNER = (unsigned int)-1
+};
+
/**
* Create a new bare Git index object as a memory representation
* of the Git index file in 'index_path', without a repository
@@ -127,6 +135,27 @@ GIT_EXTERN(void) git_index_clear(git_index *index);
GIT_EXTERN(void) git_index_free(git_index *index);
/**
+ * Read index capabilities flags.
+ *
+ * @param index An existing index object
+ * @return A combination of GIT_INDEXCAP values
+ */
+GIT_EXTERN(unsigned int) git_index_caps(const git_index *index);
+
+/**
+ * Set index capabilities flags.
+ *
+ * If you pass `GIT_INDEXCAP_FROM_OWNER` for the caps, then the
+ * capabilities will be read from the config of the owner object,
+ * looking at `core.ignorecase`, `core.filemode`, `core.symlinks`.
+ *
+ * @param index An existing index object
+ * @param caps A combination of GIT_INDEXCAP values
+ * @return 0 on success, -1 on failure
+ */
+GIT_EXTERN(int) git_index_set_caps(git_index *index, unsigned int caps);
+
+/**
* Update the contents of an existing index object in memory
* by reading from the hard disk.
*