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

[PATCH 01/16] refs: adjust names for `init` and `init_db` callbacks

From
Patrick Steinhardt <ps@pks.im>
Date
May 16, 2024, 08:04 UTC
Message-ID
<360d03474635e36a80a3b720bf0f86ac272c618e.1715836916.git.ps@pks.im>
In-Reply-To
<cover.1715836916.git.ps@pks.im>

The names of the functions that implement the the `init` and `init_db` callbacks in the "files" and "packed" backends do not match the names of the callbacks, which is inconsistent. Rename them so that they match, which makes it easier to discover their respective implementations.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 refs/files-backend.c  | 10 +++++-----
 refs/packed-backend.c | 16 ++++++++--------
 refs/packed-backend.h |  6 +++---
 3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/refs/files-backend.c b/refs/files-backend.c
index a098d14ea0..2c9d5e0747 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -89,9 +89,9 @@ static void clear_loose_ref_cache(struct files_ref_store *refs)
  * Create a new submodule ref cache and add it to the internal
  * set of caches.
  */
-static struct ref_store *files_ref_store_create(struct repository *repo,
-						const char *gitdir,
-						unsigned int flags)
+static struct ref_store *files_ref_store_init(struct repository *repo,
+					      const char *gitdir,
+					      unsigned int flags)
 {
 	struct files_ref_store *refs = xcalloc(1, sizeof(*refs));
 	struct ref_store *ref_store = (struct ref_store *)refs;
@@ -102,7 +102,7 @@ static struct ref_store *files_ref_store_create(struct repository *repo,
 	get_common_dir_noenv(&sb, gitdir);
 	refs->gitcommondir = strbuf_detach(&sb, NULL);
 	refs->packed_ref_store =
-		packed_ref_store_create(repo, refs->gitcommondir, flags);
+		packed_ref_store_init(repo, refs->gitcommondir, flags);
 
 	chdir_notify_reparent("files-backend $GIT_DIR", &refs->base.gitdir);
 	chdir_notify_reparent("files-backend $GIT_COMMONDIR",
@@ -3283,7 +3283,7 @@ static int files_init_db(struct ref_store *ref_store,
 
 struct ref_storage_be refs_be_files = {
 	.name = "files",
-	.init = files_ref_store_create,
+	.init = files_ref_store_init,
 	.init_db = files_init_db,
 	.transaction_prepare = files_transaction_prepare,
 	.transaction_finish = files_transaction_finish,
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 4e826c05ff..a3c5a75073 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -200,9 +200,9 @@ static int release_snapshot(struct snapshot *snapshot)
 	}
 }
 
-struct ref_store *packed_ref_store_create(struct repository *repo,
-					  const char *gitdir,
-					  unsigned int store_flags)
+struct ref_store *packed_ref_store_init(struct repository *repo,
+					const char *gitdir,
+					unsigned int store_flags)
 {
 	struct packed_ref_store *refs = xcalloc(1, sizeof(*refs));
 	struct ref_store *ref_store = (struct ref_store *)refs;
@@ -1244,9 +1244,9 @@ int packed_refs_is_locked(struct ref_store *ref_store)
 static const char PACKED_REFS_HEADER[] =
 	"# pack-refs with: peeled fully-peeled sorted \n";
 
-static int packed_init_db(struct ref_store *ref_store UNUSED,
-			  int flags UNUSED,
-			  struct strbuf *err UNUSED)
+static int packed_ref_store_init_db(struct ref_store *ref_store UNUSED,
+				    int flags UNUSED,
+				    struct strbuf *err UNUSED)
 {
 	/* Nothing to do. */
 	return 0;
@@ -1706,8 +1706,8 @@ static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_s
 
 struct ref_storage_be refs_be_packed = {
 	.name = "packed",
-	.init = packed_ref_store_create,
-	.init_db = packed_init_db,
+	.init = packed_ref_store_init,
+	.init_db = packed_ref_store_init_db,
 	.transaction_prepare = packed_transaction_prepare,
 	.transaction_finish = packed_transaction_finish,
 	.transaction_abort = packed_transaction_abort,
diff --git a/refs/packed-backend.h b/refs/packed-backend.h
index 9dd8a344c3..09437ad13b 100644
--- a/refs/packed-backend.h
+++ b/refs/packed-backend.h
@@ -13,9 +13,9 @@ struct ref_transaction;
  * even among packed refs.
  */
 
-struct ref_store *packed_ref_store_create(struct repository *repo,
-					  const char *gitdir,
-					  unsigned int store_flags);
+struct ref_store *packed_ref_store_init(struct repository *repo,
+					const char *gitdir,
+					unsigned int store_flags);
 
 /*
  * Lock the packed-refs file for writing. Flags is passed to
-- 
2.45.1.190.g19fe900cfc.dirty
Previous: Patrick SteinhardtNext: Karthik Nayak
Message 2 of 33 in “refs: drop all references to `the_repository`”
  1. 00/16 refs: drop all references to `the_repository`Patrick Steinhardt, May 16, 2024
  2. 01/16 refs: adjust names for `init` and `init_db` callbacksPatrick Steinhardt, May 16, 2024
  3. Karthik NayakMay 16, 2024
  4. 02/16 refs: rename `init_db` callback to avoid confusionPatrick Steinhardt, May 16, 2024
  5. Karthik NayakMay 16, 2024
  6. Junio C HamanoMay 16, 2024
  7. Patrick SteinhardtMay 17, 2024
  8. 03/16 refs: implement releasing ref storagesPatrick Steinhardt, May 16, 2024
  9. Karthik NayakMay 16, 2024
  10. Junio C HamanoMay 16, 2024
  11. Patrick SteinhardtMay 17, 2024
  12. Patrick SteinhardtMay 17, 2024
  13. 04/16 refs: track ref stores via strmapPatrick Steinhardt, May 16, 2024
  14. Junio C HamanoMay 16, 2024
  15. 05/16 refs: pass repo when retrieving submodule ref storePatrick Steinhardt, May 16, 2024
  16. Junio C HamanoMay 16, 2024
  17. Patrick SteinhardtMay 17, 2024
  18. 06/16 refs: refactor `resolve_gitlink_ref()` to accept a repositoryPatrick Steinhardt, May 16, 2024
  19. Junio C HamanoMay 16, 2024
  20. 07/16 refs: retrieve worktree ref stores via associated repositoryPatrick Steinhardt, May 16, 2024
  21. 08/16 refs: convert iteration over replace refs to accept ref storePatrick Steinhardt, May 16, 2024
  22. 09/16 refs: pass ref store when detecting dangling symrefsPatrick Steinhardt, May 16, 2024
  23. 10/16 refs: move object peeling into "object.c"Patrick Steinhardt, May 16, 2024
  24. Junio C HamanoMay 16, 2024
  25. 11/16 refs: pass repo when peeling objectsPatrick Steinhardt, May 16, 2024
  26. 12/16 refs: drop `git_default_branch_name()`Patrick Steinhardt, May 16, 2024
  27. Karthik NayakMay 16, 2024
  28. 13/16 refs: remove `dwim_log()`Patrick Steinhardt, May 16, 2024
  29. 14/16 refs/files: use correct repositoryPatrick Steinhardt, May 16, 2024
  30. 15/16 refs/files: remove references to `the_hash_algo`Patrick Steinhardt, May 16, 2024
  31. 16/16 refs/packed: remove references to `the_hash_algo`Patrick Steinhardt, May 16, 2024
  32. Karthik NayakMay 16, 2024
  33. Patrick SteinhardtMay 17, 2024

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.