path: root/refs/ref-cache.h
diff options
authorMichael Haggerty <>2017-04-16 06:41:39 (GMT)
committerJunio C Hamano <>2017-04-17 04:32:46 (GMT)
commit059ae35a4871428f49500a22fd0b3eb6e1b424c3 (patch)
tree4adad905d2ba47efd2a9274a9219ad21dec21c9c /refs/ref-cache.h
parenta714b19ca81607e53ddbde41eb9082b435148e73 (diff)
cache_ref_iterator_begin(): make function smarter
Change `cache_ref_iterator_begin()` to take two new arguments: * `prefix` -- to iterate only over references with the specified prefix. * `prime_dir` -- to "prime" (i.e., pre-load) the cache before starting the iteration. The new functionality makes it possible for `files_ref_iterator_begin()` to be made more ignorant of the internals of `ref_cache`, and `find_containing_dir()` and `prime_ref_dir()` to be made private. Signed-off-by: Michael Haggerty <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'refs/ref-cache.h')
1 files changed, 9 insertions, 18 deletions
diff --git a/refs/ref-cache.h b/refs/ref-cache.h
index 6eecdf4..5e7a918 100644
--- a/refs/ref-cache.h
+++ b/refs/ref-cache.h
@@ -235,25 +235,21 @@ int remove_entry_from_dir(struct ref_dir *dir, const char *refname);
int add_ref_entry(struct ref_dir *dir, struct ref_entry *ref);
- * If refname is a reference name, find the ref_dir within the dir
- * tree that should hold refname. If refname is a directory name
- * (i.e., it ends in '/'), then return that ref_dir itself. dir must
- * represent the top-level directory and must already be complete.
- * Sort ref_dirs and recurse into subdirectories as necessary. If
- * mkdir is set, then create any missing directories; otherwise,
- * return NULL if the desired directory cannot be found.
- */
-struct ref_dir *find_containing_dir(struct ref_dir *dir,
- const char *refname, int mkdir);
* Find the value entry with the given name in dir, sorting ref_dirs
* and recursing into subdirectories as necessary. If the name is not
* found or it corresponds to a directory entry, return NULL.
struct ref_entry *find_ref_entry(struct ref_dir *dir, const char *refname);
-struct ref_iterator *cache_ref_iterator_begin(struct ref_dir *dir);
+ * Start iterating over references in `cache`. If `prefix` is
+ * specified, only include references whose names start with that
+ * prefix. If `prime_dir` is true, then fill any incomplete
+ * directories before beginning the iteration.
+ */
+struct ref_iterator *cache_ref_iterator_begin(struct ref_cache *cache,
+ const char *prefix,
+ int prime_dir);
typedef int each_ref_entry_fn(struct ref_entry *entry, void *cb_data);
@@ -279,9 +275,4 @@ int do_for_each_entry_in_dir(struct ref_dir *dir,
enum peel_status peel_entry(struct ref_entry *entry, int repeel);
- * Load all of the refs from `dir` into our in-memory cache.
- */
-void prime_ref_dir(struct ref_dir *dir);
#endif /* REFS_REF_CACHE_H */