[PATCH v2 19/23] refs.c: add reflog backend methods
STALE3760d
From: Ronnie Sahlberg <hidden>
Date: 2016-06-15 23:02:15
Subsystem:
the rest · Maintainer:
Linus Torvalds
Revision v2 of 3 in this series.
Revisions (3)
- v1 [diff vs current]
- v2 current
- v3 [diff vs current]
Add methods for the reflog functions. Signed-off-by: Ronnie Sahlberg <redacted> --- refs-common.c | 32 ++++++++++++++++++++++++++++++++ refs.c | 18 ++++++++++++------ refs.h | 17 +++++++++++++++++ 3 files changed, 61 insertions(+), 6 deletions(-)
diff --git a/refs-common.c b/refs-common.c
index e7cea02..68152d6 100644
--- a/refs-common.c
+++ b/refs-common.c@@ -853,3 +853,35 @@ void transaction_free(struct ref_transaction *transaction) { return refs->transaction_free(transaction); } + +int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, + void *cb_data) +{ + return refs->for_each_reflog_ent_reverse(refname, fn, cb_data); +} + +int for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn, + void *cb_data) +{ + return refs->for_each_reflog_ent(refname, fn, cb_data); +} + +int for_each_reflog(each_ref_fn fn, void *cb_data) +{ + return refs->for_each_reflog(fn, cb_data); +} + +int reflog_exists(const char *refname) +{ + return refs->reflog_exists(refname); +} + +int create_reflog(const char *refname) +{ + return refs->create_reflog(refname); +} + +int delete_reflog(const char *refname) +{ + return refs->delete_reflog(refname); +}
diff --git a/refs.c b/refs.c
index 27eafd0..699b548 100644
--- a/refs.c
+++ b/refs.c@@ -2251,7 +2251,7 @@ static int copy_msg(char *buf, const char *msg) } /* This function must set a meaningful errno on failure */ -int create_reflog(const char *refname) +static int files_create_reflog(const char *refname) { int logfd, oflags = O_APPEND | O_WRONLY; char logfile[PATH_MAX];
@@ -2516,7 +2516,7 @@ int create_symref(const char *ref_target, const char *refs_heads_master, return 0; } -int reflog_exists(const char *refname) +static int files_reflog_exists(const char *refname) { struct stat st;
@@ -2524,7 +2524,7 @@ int reflog_exists(const char *refname) S_ISREG(st.st_mode); } -int delete_reflog(const char *refname) +static int files_delete_reflog(const char *refname) { return remove_path(git_path("logs/%s", refname)); }
@@ -2568,7 +2568,7 @@ static char *find_beginning_of_line(char *bob, char *scan) return scan; } -int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, void *cb_data) +static int files_for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, void *cb_data) { struct strbuf sb = STRBUF_INIT; FILE *logfp;
@@ -2645,7 +2645,7 @@ int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, void return ret; } -int for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn, void *cb_data) +static int files_for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn, void *cb_data) { FILE *logfp; struct strbuf sb = STRBUF_INIT;
@@ -2706,7 +2706,7 @@ static int do_for_each_reflog(struct strbuf *name, each_ref_fn fn, void *cb_data return retval; } -int for_each_reflog(each_ref_fn fn, void *cb_data) +static int files_for_each_reflog(each_ref_fn fn, void *cb_data) { int retval; struct strbuf name;
@@ -3295,6 +3295,12 @@ struct ref_be refs_files = { files_transaction_update_reflog, files_transaction_commit, files_transaction_free, + files_for_each_reflog_ent, + files_for_each_reflog_ent_reverse, + files_for_each_reflog, + files_reflog_exists, + files_create_reflog, + files_delete_reflog, }; struct ref_be *refs = &refs_files;
diff --git a/refs.h b/refs.h
index 4b669f5..302eb03 100644
--- a/refs.h
+++ b/refs.h@@ -373,6 +373,17 @@ typedef int (*transaction_commit_fn)(struct ref_transaction *transaction, struct strbuf *err); typedef void (*transaction_free_fn)(struct ref_transaction *transaction); +typedef int (*for_each_reflog_ent_fn)(const char *refname, + each_reflog_ent_fn fn, + void *cb_data); +typedef int (*for_each_reflog_ent_reverse_fn)(const char *refname, + each_reflog_ent_fn fn, + void *cb_data); +typedef int (*for_each_reflog_fn)(each_ref_fn fn, void *cb_data); +typedef int (*reflog_exists_fn)(const char *refname); +typedef int (*create_reflog_fn)(const char *refname); +typedef int (*delete_reflog_fn)(const char *refname); + struct ref_be { transaction_begin_fn transaction_begin; transaction_update_sha1_fn transaction_update_sha1;
@@ -381,6 +392,12 @@ struct ref_be { transaction_update_reflog_fn transaction_update_reflog; transaction_commit_fn transaction_commit; transaction_free_fn transaction_free; + for_each_reflog_ent_fn for_each_reflog_ent; + for_each_reflog_ent_reverse_fn for_each_reflog_ent_reverse; + for_each_reflog_fn for_each_reflog; + reflog_exists_fn reflog_exists; + create_reflog_fn create_reflog; + delete_reflog_fn delete_reflog; }; extern struct ref_be *refs;
--
2.0.1.556.g3edca4c