path: root/repository.h
diff options
authorBrandon Williams <>2017-07-18 19:05:18 (GMT)
committerJunio C Hamano <>2017-07-18 20:32:25 (GMT)
commit3f13877595500bd54ee370167bc868f3c1eee5b7 (patch)
tree6a7940cc0ac743cc9b997cc6c6d7a4a7c41b4b68 /repository.h
parentf3da2b79be9565779e4f76dc5812c68e156afdf0 (diff)
repo_read_index: don't discard the index
Have 'repo_read_index()' behave more like the other read_index family of functions and don't discard the index if it has already been populated and instead rely on the quick return of read_index_from which has: /* istate->initialized covers both .git/index and .git/ */ if (istate->initialized) return istate->cache_nr; Signed-off-by: Brandon Williams <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'repository.h')
1 files changed, 8 insertions, 0 deletions
diff --git a/repository.h b/repository.h
index 417787f..7f5e24a 100644
--- a/repository.h
+++ b/repository.h
@@ -92,6 +92,14 @@ extern int repo_submodule_init(struct repository *submodule,
const char *path);
extern void repo_clear(struct repository *repo);
+ * Populates the repository's index from its index_file, an index struct will
+ * be allocated if needed.
+ *
+ * Return the number of index entries in the populated index or a value less
+ * than zero if an error occured. If the repository's index has already been
+ * populated then the number of entries will simply be returned.
+ */
extern int repo_read_index(struct repository *repo);
#endif /* REPOSITORY_H */