Thread (51 messages) 51 messages, 6 authors, 2016-06-15
STALE3756d

Revision v6 of 3 in this series.

Revisions (3)
  1. v4 [diff vs current]
  2. v6 current
  3. v7 [diff vs current]

[PATCH v6 07/32] refs: add method for do_for_each_ref

From: David Turner <hidden>
Date: 2016-06-15 23:08:25
Subsystem: the rest · Maintainer: Linus Torvalds

Add a ref backend method for do_for_each_ref.

Signed-off-by: David Turner <redacted>
---
 refs.c               | 8 ++++++++
 refs/files-backend.c | 7 +++++--
 refs/refs-internal.h | 5 +++++
 3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/refs.c b/refs.c
index 6fd5121..cd06f4b 100644
--- a/refs.c
+++ b/refs.c
@@ -1339,3 +1339,11 @@ int resolve_gitlink_ref(const char *path, const char *refname,
 {
 	return the_refs_backend->resolve_gitlink_ref(path, refname, sha1);
 }
+
+int do_for_each_ref(const char *submodule, const char *base,
+		    each_ref_fn fn, int trim, int flags,
+		    void *cb_data)
+{
+	return the_refs_backend->do_for_each_ref(submodule, base, fn, trim,
+						 flags, cb_data);
+}
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 3a83c0d..db9e948 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1679,8 +1679,9 @@ static int do_for_each_entry(struct ref_cache *refs, const char *base,
  * value, stop the iteration and return that value; otherwise, return
  * 0.
  */
-int do_for_each_ref(const char *submodule, const char *base,
-		    each_ref_fn fn, int trim, int flags, void *cb_data)
+static int files_do_for_each_ref(const char *submodule, const char *base,
+				 each_ref_fn fn, int trim, int flags,
+				 void *cb_data)
 {
 	struct ref_entry_cb data;
 	struct ref_cache *refs;
@@ -3415,4 +3416,6 @@ struct ref_storage_be refs_be_files = {
 	files_read_raw_ref,
 	files_verify_refname_available,
 	files_resolve_gitlink_ref,
+
+	files_do_for_each_ref,
 };
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index c5f5ef7..c9b6745 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -227,6 +227,9 @@ typedef int read_raw_ref_fn(const char *refname, unsigned char *sha1,
 typedef int verify_refname_available_fn(const char *refname, struct string_list *extra, struct string_list *skip, struct strbuf *err);
 typedef int resolve_gitlink_ref_fn(const char *path, const char *refname,
 				   unsigned char *sha1);
+typedef int do_for_each_ref_fn(const char *submodule, const char *base,
+			       each_ref_fn fn, int trim, int flags,
+			       void *cb_data);
 
 struct ref_storage_be {
 	struct ref_storage_be *next;
@@ -240,6 +243,8 @@ struct ref_storage_be {
 	read_raw_ref_fn *read_raw_ref;
 	verify_refname_available_fn *verify_refname_available;
 	resolve_gitlink_ref_fn *resolve_gitlink_ref;
+
+	do_for_each_ref_fn *do_for_each_ref;
 };
 
 extern struct ref_storage_be refs_be_files;
-- 
2.4.2.767.g62658d5-twtrsrc
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help