summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-02-07 14:10:35 -0800
committerRussell Belfer <rb@github.com>2014-04-17 14:43:45 -0700
commit3dbee456564a9baf24631bfe219f81434d8fdfa6 (patch)
treec9291c06be39e6c3e576589c34a84f70c1499cd2 /include
parentc67fd4c9d5e1ff715df28b884d7f7f9f20fad1ec (diff)
downloadlibgit2-3dbee456564a9baf24631bfe219f81434d8fdfa6.tar.gz
Some index internals refactoring
Again, laying groundwork for some index iterator changes, this contains a bunch of code refactorings for index internals that should make it easier down the line to add locking around index modifications. Also this removes the redundant prefix_position function and fixes some potential memory leaks.
Diffstat (limited to 'include')
-rw-r--r--include/git2/index.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/include/git2/index.h b/include/git2/index.h
index dd6a28e40..4d33f13d2 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -77,7 +77,12 @@ typedef struct git_index_entry {
#define GIT_IDXENTRY_VALID (0x8000)
#define GIT_IDXENTRY_STAGESHIFT 12
-#define GIT_IDXENTRY_STAGE(E) (((E)->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT)
+#define GIT_IDXENTRY_STAGE(E) \
+ (((E)->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT)
+
+#define GIT_IDXENTRY_STAGE_SET(E,S) do { \
+ (E)->flags = ((E)->flags & ~GIT_IDXENTRY_STAGEMASK) | \
+ (((S) & 0x03) << GIT_IDXENTRY_STAGESHIFT); } while (0)
/**
* Bitmasks for on-disk fields of `git_index_entry`'s `flags_extended`
@@ -327,12 +332,14 @@ GIT_EXTERN(size_t) git_index_entrycount(const git_index *index);
/**
* Clear the contents (all the entries) of an index object.
- * This clears the index object in memory; changes must be manually
- * written to disk for them to take effect.
+ *
+ * This clears the index object in memory; changes must be explicitly
+ * written to disk for them to take effect persistently.
*
* @param index an existing index object
+ * @return 0 on success, error code < 0 on failure
*/
-GIT_EXTERN(void) git_index_clear(git_index *index);
+GIT_EXTERN(int) git_index_clear(git_index *index);
/**
* Get a pointer to one of the entries in the index