summaryrefslogtreecommitdiff
path: root/src/index.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.h')
-rw-r--r--src/index.h36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/index.h b/src/index.h
index 17f04f0ad..50a0b4b6c 100644
--- a/src/index.h
+++ b/src/index.h
@@ -21,12 +21,15 @@ struct git_index {
git_refcount rc;
char *index_file_path;
-
git_futils_filestamp stamp;
+
git_vector entries;
- unsigned int on_disk:1;
+ git_mutex lock; /* lock held while entries is being changed */
+ git_vector deleted; /* deleted entries if readers > 0 */
+ git_atomic readers; /* number of active iterators */
+ unsigned int on_disk:1;
unsigned int ignore_case:1;
unsigned int distrust_filemode:1;
unsigned int no_symlinks:1;
@@ -50,12 +53,21 @@ struct git_index_conflict_iterator {
extern void git_index_entry__init_from_stat(
git_index_entry *entry, struct stat *st, bool trust_mode);
-extern size_t git_index__prefix_position(git_index *index, const char *path);
+/* Index entry comparison functions for array sorting */
+extern int git_index_entry_cmp(const void *a, const void *b);
+extern int git_index_entry_icmp(const void *a, const void *b);
-extern int git_index_entry__cmp(const void *a, const void *b);
-extern int git_index_entry__cmp_icase(const void *a, const void *b);
+/* Index entry search functions for search using a search spec */
+extern int git_index_entry_srch(const void *a, const void *b);
+extern int git_index_entry_isrch(const void *a, const void *b);
-extern int git_index__find(
+/* Search index for `path`, returning GIT_ENOTFOUND if it does not exist
+ * (but not setting an error message).
+ *
+ * `at_pos` is set to the position where it is or would be inserted.
+ * Pass `path_len` as strlen of path or 0 to call strlen internally.
+ */
+extern int git_index__find_pos(
size_t *at_pos, git_index *index, const char *path, size_t path_len, int stage);
extern void git_index__set_ignore_case(git_index *index, bool ignore_case);
@@ -69,4 +81,16 @@ GIT_INLINE(const git_futils_filestamp *) git_index__filestamp(git_index *index)
extern int git_index__changed_relative_to(git_index *index, const git_futils_filestamp *fs);
+/* Copy the current entries vector *and* increment the index refcount.
+ * Call `git_index__release_snapshot` when done.
+ */
+extern int git_index_snapshot_new(git_vector *snap, git_index *index);
+extern void git_index_snapshot_release(git_vector *snap, git_index *index);
+
+/* Allow searching in a snapshot; entries must already be sorted! */
+extern int git_index_snapshot_find(
+ size_t *at_pos, git_vector *snap, git_vector_cmp entry_srch,
+ const char *path, size_t path_len, int stage);
+
+
#endif