[PATCH 28/43] refs.c: add ref backend init function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The file backend doesn't need this function, but other backends might.

Signed-off-by: David Turner <dturner@xxxxxxxxxxx>
Signed-off-by: Ronnie Sahlberg <rsahlberg@xxxxxxxxxx>
---
 refs-be-files.c | 1 +
 refs.c          | 4 +++-
 refs.h          | 4 +++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/refs-be-files.c b/refs-be-files.c
index 3138624..6a10d4b 100644
--- a/refs-be-files.c
+++ b/refs-be-files.c
@@ -3722,6 +3722,7 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
 struct ref_be refs_be_files = {
 	NULL,
 	"files",
+	NULL,
 	files_transaction_begin,
 	files_transaction_update,
 	files_transaction_create,
diff --git a/refs.c b/refs.c
index a9e6ca1..60f3503 100644
--- a/refs.c
+++ b/refs.c
@@ -19,13 +19,15 @@ struct ref_be *refs_backends = &refs_be_files;
 /*
  * This function is used to switch to an alternate backend.
  */
-int set_refs_backend(const char *name)
+int set_refs_backend(const char *name, void *init_data)
 {
 	struct ref_be *be;
 
 	for (be = refs_backends; be; be = be->next)
 		if (!strcmp(be->name, name)) {
 			the_refs_backend = be;
+			if (be->init_backend)
+				be->init_backend(init_data);
 			return 0;
 		}
 	return 1;
diff --git a/refs.h b/refs.h
index 7204a56..d594a12 100644
--- a/refs.h
+++ b/refs.h
@@ -586,6 +586,7 @@ extern int reflog_expire(const char *refname, const unsigned char *sha1,
 			 void *policy_cb_data);
 
 /* refs backends */
+typedef void (*ref_backend_init_fn)(void *data);
 typedef struct ref_transaction *(*ref_transaction_begin_fn)(struct strbuf *err);
 typedef int (*ref_transaction_update_fn)(struct ref_transaction *transaction,
 		const char *refname, const unsigned char *new_sha1,
@@ -635,6 +636,7 @@ typedef int (*for_each_reftype_fullpath_fn)(each_ref_fn fn, char *type, unsigned
 struct ref_be {
 	struct ref_be *next;
 	const char *name;
+	ref_backend_init_fn init_backend;
 	ref_transaction_begin_fn transaction_begin;
 	ref_transaction_update_fn transaction_update;
 	ref_transaction_create_fn transaction_create;
@@ -662,6 +664,6 @@ struct ref_be {
 
 
 extern struct ref_be refs_be_files;
-int set_refs_backend(const char *name);
+int set_refs_backend(const char *name, void *init_data);
 
 #endif /* REFS_H */
-- 
2.0.4.315.gad8727a-twtrsrc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]