From: Ronnie Sahlberg <sahlberg@google.com>
To: git@vger.kernel.org
Cc: Ronnie Sahlberg <sahlberg@google.com>
Subject: [PATCH v2 19/23] refs.c: add reflog backend methods
Date: Wed, 13 Aug 2014 13:15:03 -0700 [thread overview]
Message-ID: <1407960907-18189-20-git-send-email-sahlberg@google.com> (raw)
In-Reply-To: <1407960907-18189-1-git-send-email-sahlberg@google.com>
Add methods for the reflog functions.
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
---
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
next prev parent reply other threads:[~2014-08-13 20:15 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 20:14 [PATCH v2 00/23] backend-struct-db Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 01/23] refs.c: create a public function for is_refname_available Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 02/23] refs-common.c: create a file to host all common refs code Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 03/23] refs-common.c: move update_ref to refs-common.c Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 04/23] refs-common.c: move delete_ref to the common code Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 05/23] refs-common.c: move rename_ref " Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 06/23] refs-common.c: move read_ref_at to the refs common file Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 07/23] refs-common.c: move the hidden refs functions to the common code Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 08/23] refs-common.c: move dwim and friend functions to refs common Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 09/23] refs-common.c: move warn_if_dangling_symref* to refs-common Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 10/23] refs-common.c: move read_ref, read_ref_full and ref_exists to common Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 11/23] refs-common.c: move resolve_refdup " Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 12/23] refs-common.c: move check_refname_component to the common code Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 13/23] refs-common.c: move is_branch " Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 14/23] refs-common.c: move names_conflict " Ronnie Sahlberg
2014-08-13 20:14 ` [PATCH v2 15/23] refs-common.c: move prettify_refname " Ronnie Sahlberg
2014-08-13 20:15 ` [PATCH v2 16/23] refs-common.c: move ref iterators " Ronnie Sahlberg
2014-08-13 20:15 ` [PATCH v2 17/23] refs-common.c: move head_ref_namespaced to the common file Ronnie Sahlberg
2014-08-13 20:15 ` [PATCH v2 18/23] refs.c: add a backend method structure with transaction functions Ronnie Sahlberg
2014-08-26 21:25 ` Junio C Hamano
2014-08-26 22:11 ` Ronnie Sahlberg
2014-08-13 20:15 ` Ronnie Sahlberg [this message]
2014-08-13 20:15 ` [PATCH v2 20/23] refs.c: add methods for misc ref operations Ronnie Sahlberg
2014-08-13 20:15 ` [PATCH v2 21/23] refs.c: add methods for head_ref* Ronnie Sahlberg
2014-08-13 20:15 ` [PATCH v2 22/23] refs.c: add methods for the ref iterators Ronnie Sahlberg
2014-08-13 21:18 ` [PATCH v2 00/23] backend-struct-db Junio C Hamano
2014-08-13 21:55 ` Ronnie Sahlberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407960907-18189-20-git-send-email-sahlberg@google.com \
--to=sahlberg@google.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).