git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 11/43] refs.c: move read_ref, read_ref_full and ref_exists to the common code

From
David Turner <dturner@twopensource.com>
Date
Sep 3, 2015, 01:54 UTC
Message-ID
<1441245313-11907-12-git-send-email-dturner@twopensource.com>
In-Reply-To
<1441245313-11907-1-git-send-email-dturner@twopensource.com>
From: Ronnie Sahlberg <sahlberg@google.com>

These functions do not depend on the backend implementation so we move them to the common code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: David Turner <dturner@twitter.com>
---
 refs-be-files.c | 18 ------------------
 refs.c          | 18 ++++++++++++++++++
 2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/refs-be-files.c b/refs-be-files.c
index 9c0dd5c..f67ff41 100644
--- a/refs-be-files.c
+++ b/refs-be-files.c
@@ -1800,24 +1800,6 @@ struct ref_filter {
 	void *cb_data;
 };
 
-int read_ref_full(const char *refname, int resolve_flags, unsigned char *sha1, int *flags)
-{
-	if (resolve_ref_unsafe(refname, resolve_flags, sha1, flags))
-		return 0;
-	return -1;
-}
-
-int read_ref(const char *refname, unsigned char *sha1)
-{
-	return read_ref_full(refname, RESOLVE_REF_READING, sha1, NULL);
-}
-
-int ref_exists(const char *refname)
-{
-	unsigned char sha1[20];
-	return !!resolve_ref_unsafe(refname, RESOLVE_REF_READING, sha1, NULL);
-}
-
 static int filter_refs(const char *refname, const struct object_id *oid,
 			   int flags, void *data)
 {
diff --git a/refs.c b/refs.c
index 24d5e28..242f66d 100644
--- a/refs.c
+++ b/refs.c
@@ -633,3 +633,21 @@ void warn_dangling_symrefs(FILE *fp, const char *msg_fmt, const struct string_li
 	data.msg_fmt = msg_fmt;
 	for_each_rawref(warn_if_dangling_symref, &data);
 }
+
+int read_ref_full(const char *refname, int resolve_flags, unsigned char *sha1, int *flags)
+{
+	if (resolve_ref_unsafe(refname, resolve_flags, sha1, flags))
+		return 0;
+	return -1;
+}
+
+int read_ref(const char *refname, unsigned char *sha1)
+{
+	return read_ref_full(refname, RESOLVE_REF_READING, sha1, NULL);
+}
+
+int ref_exists(const char *refname)
+{
+	unsigned char sha1[20];
+	return !!resolve_ref_unsafe(refname, RESOLVE_REF_READING, sha1, NULL);
+}
-- 
2.0.4.315.gad8727a-twtrsrc
Previous: David TurnerNext: David Turner
Message 13 of 54 in “refs lmdb backend”
  1. 00/43 refs lmdb backendDavid Turner, Sep 3, 2015
  2. 01/43 refs.c: create a public version of verify_refname_availableDavid Turner, Sep 3, 2015
  3. Junio C HamanoSep 3, 2015
  4. David TurnerSep 4, 2015
  5. 02/43 refs: make repack_without_refs and is_branch publicDavid Turner, Sep 3, 2015
  6. 04/43 refs.c: add a new refs.c file to hold all common refs codeDavid Turner, Sep 3, 2015
  7. 05/43 refs.c: move update_ref to refs.cDavid Turner, Sep 3, 2015
  8. 06/43 refs.c: move delete_ref and delete_refs to the common codeDavid Turner, Sep 3, 2015
  9. 07/43 refs.c: move read_ref_at to the common refs fileDavid Turner, Sep 3, 2015
  10. 08/43 refs.c: move the hidden refs functions to the common codeDavid Turner, Sep 3, 2015
  11. 09/43 refs.c: move dwim and friend functions to the common refs codeDavid Turner, Sep 3, 2015
  12. 10/43 refs.c: move warn_if_dangling_symref* to the common codeDavid Turner, Sep 3, 2015
  13. 11/43 refs.c: move read_ref, read_ref_full and ref_exists to the common codeDavid Turner, Sep 3, 2015
  14. 12/43 refs.c: move resolve_refdup to commonDavid Turner, Sep 3, 2015
  15. 13/43 refs.c: move check_refname_format to the common codeDavid Turner, Sep 3, 2015
  16. 14/43 refs.c: move is_branch to the common codeDavid Turner, Sep 3, 2015
  17. 15/43 refs.c: move prettify_refname to the common codeDavid Turner, Sep 3, 2015
  18. 16/43 refs.c: move ref iterators to the common codeDavid Turner, Sep 3, 2015
  19. 17/43 refs.c: move head_ref_namespaced to the common codeDavid Turner, Sep 3, 2015
  20. 18/43 refs-be-files.c: add a backend method structure with transaction functionsDavid Turner, Sep 3, 2015
  21. 19/43 refs-be-files.c: add methods for misc ref operationsDavid Turner, Sep 3, 2015
  22. 20/43 refs-be-files.c: add methods for the ref iteratorsDavid Turner, Sep 3, 2015
  23. Junio C HamanoSep 25, 2015
  24. David TurnerSep 25, 2015
  25. Junio C HamanoSep 25, 2015
  26. 21/43 refs-be-files.c: add method for for_each_reftype_...David Turner, Sep 3, 2015
  27. 22/43 refs-be-files.c: add do_for_each_per_worktree_refDavid Turner, Sep 3, 2015
  28. 23/43 refs.c: move refname_is_safe to the common codeDavid Turner, Sep 3, 2015
  29. 24/43 refs.h: document make refname_is_safe and add it to headerDavid Turner, Sep 3, 2015
  30. David TurnerSep 3, 2015
  31. 25/43 refs.c: move copy_msg to the common codeDavid Turner, Sep 3, 2015
  32. 26/43 refs.c: move peel_object to the common codeDavid Turner, Sep 3, 2015
  33. 27/43 refs.c: move should_autocreate_reflog to common codeDavid Turner, Sep 3, 2015
  34. 28/43 refs.c: add ref backend init functionDavid Turner, Sep 3, 2015
  35. 29/43 refs.c: add methods for reflogDavid Turner, Sep 3, 2015
  36. 30/43 refs.c: add method for initial ref transaction commitDavid Turner, Sep 3, 2015
  37. 31/43 initdb: move safe_create_dir into common codeDavid Turner, Sep 3, 2015
  38. 32/43 refs.c: add method for initializing refs dbDavid Turner, Sep 3, 2015
  39. 33/43 refs.c: make struct ref_transaction genericDavid Turner, Sep 3, 2015
  40. 34/43 refs-be-files.c: add method to rename refsDavid Turner, Sep 3, 2015
  41. 35/43 refs-be-files.c: add method to expire reflogsDavid Turner, Sep 3, 2015
  42. 36/43 run-command: track total number of commands runDavid Turner, Sep 3, 2015
  43. 37/43 refs: move some defines from refs-be-files.c to refs.hDavid Turner, Sep 3, 2015
  44. 38/43 refs: make some files backend functions publicDavid Turner, Sep 3, 2015
  45. 39/43 refs: break out a ref conflict checkDavid Turner, Sep 3, 2015
  46. 40/43 refs: allow ref backend to be set for cloneDavid Turner, Sep 3, 2015
  47. 41/43 refs: add register_refs_backendDavid Turner, Sep 3, 2015
  48. 42/43 refs: add LMDB refs backendDavid Turner, Sep 3, 2015
  49. Junio C HamanoSep 3, 2015
  50. 43/43 refs: tests for db backendDavid Turner, Sep 3, 2015
  51. Junio C HamanoSep 3, 2015
  52. David TurnerSep 4, 2015
  53. David TurnerSep 17, 2015
  54. Junio C HamanoSep 17, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.