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

[PATCH 2/2] refs: switch for_each_replace_ref back to use a ref_store

From
Stefan Beller <sbeller@google.com>
Date
Jul 30, 2018, 19:47 UTC
Message-ID
<20180730194731.220191-3-sbeller@google.com>
In-Reply-To
<20180730194731.220191-1-sbeller@google.com>

This effectively reverts commit 0d296c57ae (refs: allow for_each_replace_ref to handle arbitrary repositories, 2018-04-11) and 60ce76d3581 (refs: add repository argument to for_each_replace_ref, 2018-04-11).

The repository argument is not any special from the ref-store's point of life. If you need a repository (for e.g. lookup_commit or friends), you'll have to pass it through the callback cookie, whether directly or as part of a struct tailored to your purpose.

So let's go back to the clean API, just requiring a ref_store as an argument.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/replace.c | 2 +-
 refs.c            | 4 ++--
 refs.h            | 2 +-
 replace-object.c  | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin/replace.c b/builtin/replace.c
index deabda21012..52dc371eafc 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -87,7 +87,7 @@ static int list_replace_refs(const char *pattern, const char *format)
 			     "valid formats are 'short', 'medium' and 'long'\n",
 			     format);
 
-	for_each_replace_ref(the_repository, show_reference, (void *)&data);
+	for_each_replace_ref(show_reference, (void *)&data);
 
 	return 0;
 }
diff --git a/refs.c b/refs.c
index 08fb5a99148..2d713499125 100644
--- a/refs.c
+++ b/refs.c
@@ -1441,9 +1441,9 @@ int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
 	return do_for_each_ref(refs, prefix, fn, 0, flag, cb_data);
 }
 
-int for_each_replace_ref(struct repository *r, each_ref_fn fn, void *cb_data)
+int for_each_replace_ref(each_ref_fn fn, void *cb_data)
 {
-	return do_for_each_ref(get_main_ref_store(r),
+	return do_for_each_ref(get_main_ref_store(the_repository),
 			       git_replace_ref_base, fn,
 			       strlen(git_replace_ref_base),
 			       DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
diff --git a/refs.h b/refs.h
index cc2fb4c68c0..48d5ffd2082 100644
--- a/refs.h
+++ b/refs.h
@@ -307,7 +307,7 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data,
 int for_each_tag_ref(each_ref_fn fn, void *cb_data);
 int for_each_branch_ref(each_ref_fn fn, void *cb_data);
 int for_each_remote_ref(each_ref_fn fn, void *cb_data);
-int for_each_replace_ref(struct repository *r, each_ref_fn fn, void *cb_data);
+int for_each_replace_ref(each_ref_fn fn, void *cb_data);
 int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data);
 int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
 			 const char *prefix, void *cb_data);
diff --git a/replace-object.c b/replace-object.c
index e99fcd1ff6e..ee3374ab59b 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -41,7 +41,7 @@ static void prepare_replace_object(struct repository *r)
 		xmalloc(sizeof(*r->objects->replace_map));
 	oidmap_init(r->objects->replace_map, 0);
 
-	for_each_replace_ref(r, register_replace_ref, r);
+	for_each_replace_ref(register_replace_ref, r);
 }
 
 /* We allow "recursive" replacement. Only within reason, though */
-- 
2.18.0.132.g195c49a2227
Previous: Stefan BellerNext: Jonathan Tan
Message 10 of 14 in “Migrate the refs API to take the repository argument”
  1. 0/3 Migrate the refs API to take the repository argumentStefan Beller, Jul 27, 2018
  2. 1/3 refs.c: migrate internal ref iteration to pass thru repository argumentStefan Beller, Jul 27, 2018
  3. 2/3 refs: introduce new API, wrap old API shallowly around new APIStefan Beller, Jul 27, 2018
  4. Duy NguyenJul 27, 2018
  5. Brandon WilliamsJul 27, 2018
  6. Stefan BellerJul 27, 2018
  7. Duy NguyenJul 27, 2018
  8. 0/2 Cleanup refs API [WAS: Re: [PATCH 2/3] refs: introduce new API, wrap old API shallowly around new API]Stefan Beller, Jul 30, 2018
  9. 1/2 replace-objects: use arbitrary repositoriesStefan Beller, Jul 30, 2018
  10. 2/2 refs: switch for_each_replace_ref back to use a ref_storeStefan Beller, Jul 30, 2018
  11. Jonathan TanJul 31, 2018
  12. Stefan BellerJul 31, 2018
  13. Duy NguyenJul 31, 2018
  14. 3/3 replace: migrate to for_each_replace_repo_refStefan Beller, Jul 27, 2018

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.