git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ronnie Sahlberg <sahlberg@google.com>
To: git@vger.kernel.org
Cc: Ronnie Sahlberg <sahlberg@google.com>
Subject: [PATCH v3 21/23] refs-be-files.c: add methods for misc ref operations
Date: Tue, 19 Aug 2014 09:30:45 -0700	[thread overview]
Message-ID: <1408465847-30384-22-git-send-email-sahlberg@google.com> (raw)
In-Reply-To: <1408465847-30384-1-git-send-email-sahlberg@google.com>

Add ref backend methods for:
resolve_ref_unsafe, is_refname_available, pack_refs, peel_ref,
create_symref, resolve_gitlink_ref.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
---
 refs-be-files.c | 25 ++++++++++++++++++-------
 refs.c          | 33 +++++++++++++++++++++++++++++++++
 refs.h          | 18 ++++++++++++++++++
 3 files changed, 69 insertions(+), 7 deletions(-)

diff --git a/refs-be-files.c b/refs-be-files.c
index 464d488..b09f0fc 100644
--- a/refs-be-files.c
+++ b/refs-be-files.c
@@ -1114,7 +1114,8 @@ static struct ref_dir *get_loose_refs(struct ref_cache *refs)
 	return get_ref_dir(refs->loose);
 }
 
-int is_refname_available(const char *refname, const char **skip, int skipnum)
+static int files_is_refname_available(const char *refname, const char **skip,
+				      int skipnum)
 {
 	if (!is_refname_available_dir(refname, get_packed_refs(&ref_cache),
 				      skip, skipnum))
@@ -1188,7 +1189,8 @@ static int resolve_gitlink_ref_recursive(struct ref_cache *refs,
 	return resolve_gitlink_ref_recursive(refs, p, sha1, recursion+1);
 }
 
-int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sha1)
+static int files_resolve_gitlink_ref(const char *path, const char *refname,
+				     unsigned char *sha1)
 {
 	int len = strlen(path), retval;
 	char *submodule;
@@ -1247,7 +1249,9 @@ static const char *handle_missing_loose_ref(const char *refname,
 }
 
 /* This function needs to return a meaningful errno on failure */
-const char *resolve_ref_unsafe(const char *refname, unsigned char *sha1, int flags, int *ref_flag)
+static const char *files_resolve_ref_unsafe(const char *refname,
+					    unsigned char *sha1, int flags,
+					    int *ref_flag)
 {
 	int depth = MAXDEPTH;
 	ssize_t len;
@@ -1466,7 +1470,7 @@ static enum peel_status peel_entry(struct ref_entry *entry, int repeel)
 	return status;
 }
 
-int peel_ref(const char *refname, unsigned char *sha1)
+static int files_peel_ref(const char *refname, unsigned char *sha1)
 {
 	int flag;
 	unsigned char base[20];
@@ -2080,7 +2084,7 @@ static void prune_refs(struct ref_to_prune *r)
 	}
 }
 
-int pack_refs(unsigned int flags, struct strbuf *err)
+static int files_pack_refs(unsigned int flags, struct strbuf *err)
 {
 	struct pack_refs_cb_data cbdata;
 
@@ -2453,8 +2457,9 @@ static int write_ref_sha1(struct ref_lock *lock,
 	return 0;
 }
 
-int create_symref(const char *ref_target, const char *refs_heads_master,
-		  const char *logmsg)
+static int files_create_symref(const char *ref_target,
+			       const char *refs_heads_master,
+			       const char *logmsg)
 {
 	const char *lockpath;
 	char ref[1000];
@@ -3304,6 +3309,12 @@ struct ref_be refs_files = {
 	files_reflog_exists,
 	files_create_reflog,
 	files_delete_reflog,
+	files_resolve_ref_unsafe,
+	files_is_refname_available,
+	files_pack_refs,
+	files_peel_ref,
+	files_create_symref,
+	files_resolve_gitlink_ref,
 };
 
 struct ref_be *refs = &refs_files;
diff --git a/refs.c b/refs.c
index 2db1a74..60b6241 100644
--- a/refs.c
+++ b/refs.c
@@ -888,3 +888,36 @@ int delete_reflog(const char *refname)
 {
 	return refs->delete_reflog(refname);
 }
+
+const char *resolve_ref_unsafe(const char *ref, unsigned char *sha1,
+			       int reading, int *flag)
+{
+	return refs->resolve_ref_unsafe(ref, sha1, reading, flag);
+}
+
+int is_refname_available(const char *refname, const char **skip, int skipnum)
+{
+	return refs->is_refname_available(refname, skip, skipnum);
+}
+
+int pack_refs(unsigned int flags, struct strbuf *err)
+{
+	return refs->pack_refs(flags, err);
+}
+
+int peel_ref(const char *refname, unsigned char *sha1)
+{
+	return refs->peel_ref(refname, sha1);
+}
+
+int create_symref(const char *ref_target, const char *refs_heads_master,
+		  const char *logmsg)
+{
+	return refs->create_symref(ref_target, refs_heads_master, logmsg);
+}
+
+int resolve_gitlink_ref(const char *path, const char *refname,
+			unsigned char *sha1)
+{
+	return refs->resolve_gitlink_ref(path, refname, sha1);
+}
diff --git a/refs.h b/refs.h
index 0a68986..5257437 100644
--- a/refs.h
+++ b/refs.h
@@ -382,6 +382,18 @@ 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);
+typedef const char *(*resolve_ref_unsafe_fn)(const char *ref,
+		unsigned char *sha1, int reading, int *flag);
+
+typedef int (*is_refname_available_fn)(const char *refname, const char **skip,
+				       int skipnum);
+typedef int (*pack_refs_fn)(unsigned int flags, struct strbuf *err);
+typedef int (*peel_ref_fn)(const char *refname, unsigned char *sha1);
+typedef int (*create_symref_fn)(const char *ref_target,
+				const char *refs_heads_master,
+				const char *logmsg);
+typedef int (*resolve_gitlink_ref_fn)(const char *path, const char *refname,
+				      unsigned char *sha1);
 
 struct ref_be {
 	transaction_begin_fn transaction_begin;
@@ -397,6 +409,12 @@ struct ref_be {
 	reflog_exists_fn reflog_exists;
 	create_reflog_fn create_reflog;
 	delete_reflog_fn delete_reflog;
+	resolve_ref_unsafe_fn resolve_ref_unsafe;
+	is_refname_available_fn is_refname_available;
+	pack_refs_fn pack_refs;
+	peel_ref_fn peel_ref;
+	create_symref_fn create_symref;
+	resolve_gitlink_ref_fn resolve_gitlink_ref;
 };
 
 extern struct ref_be *refs;
-- 
2.0.1.552.g1af257a

  parent reply	other threads:[~2014-08-19 16:32 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19 16:30 [PATCH v3 00/23] backend-struct-db Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 01/23] refs.c: create a public function for is_refname_available Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 03/23] refs.c: add a new refs.c file to hold all common refs code Ronnie Sahlberg
2014-08-26 21:31   ` Junio C Hamano
2014-08-26 22:00     ` Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 04/23] refs.c: move update_ref to refs.c Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 05/23] refs.c: move delete_ref to the common code Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 06/23] refs.c: move rename_ref " Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 07/23] refs.c: move read_ref_at to the common refs file Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 08/23] refs.c: move the hidden refs functions to the common code Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 09/23] refs.c: move dwim and friend functions to the common refs code Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 10/23] refs.c: move warn_if_dangling_symref* to the common code Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 11/23] refs.c: move read_ref, read_ref_full and ref_exists " Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 12/23] refs.c: move resolve_refdup to common Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 13/23] refs.c: move check_refname_component to the common code Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 14/23] refs.c: move is_branch " Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 15/23] refs.c: move names_conflict " Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 16/23] refs.c: move prettify_refname " Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 17/23] refs.c: move ref iterators " Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 18/23] refs.c: move head_ref_namespaced " Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 19/23] refs-be-files.c: add a backend method structure with transaction functions Ronnie Sahlberg
2014-08-26 21:38   ` Junio C Hamano
2014-08-26 22:34     ` Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 20/23] refs-be-files.c: add reflog backend methods Ronnie Sahlberg
2014-08-19 16:30 ` Ronnie Sahlberg [this message]
2014-08-19 16:30 ` [PATCH v3 22/23] refs-be-files.c: add methods for head_ref* Ronnie Sahlberg
2014-08-19 16:30 ` [PATCH v3 23/23] refs-be-files.c: add methods for the ref iterators 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408465847-30384-22-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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).