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

[PATCH 3/3] replace: migrate to for_each_replace_repo_ref

From
Stefan Beller <sbeller@google.com>
Date
Jul 27, 2018, 00:36 UTC
Message-ID
<20180727003640.16659-4-sbeller@google.com>
In-Reply-To
<20180727003640.16659-1-sbeller@google.com>
By upgrading the replace mechanism works well for all repositories
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/replace.c | 9 +++++----
 replace-object.c  | 7 ++++---
 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/builtin/replace.c b/builtin/replace.c
index ef22d724bbc..fd8a935eb77 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -39,7 +39,8 @@ struct show_data {
 	enum replace_format format;
 };
 
-static int show_reference(const char *refname, const struct object_id *oid,
+static int show_reference(struct repository *r, const char *refname,
+			  const struct object_id *oid,
 			  int flag, void *cb_data)
 {
 	struct show_data *data = cb_data;
@@ -56,9 +57,9 @@ static int show_reference(const char *refname, const struct object_id *oid,
 			if (get_oid(refname, &object))
 				return error("Failed to resolve '%s' as a valid ref.", refname);
 
-			obj_type = oid_object_info(the_repository, &object,
+			obj_type = oid_object_info(r, &object,
 						   NULL);
-			repl_type = oid_object_info(the_repository, oid, NULL);
+			repl_type = oid_object_info(r, oid, NULL);
 
 			printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type),
 			       oid_to_hex(oid), type_name(repl_type));
@@ -87,7 +88,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_repo_ref(the_repository, show_reference, (void *)&data);
 
 	return 0;
 }
diff --git a/replace-object.c b/replace-object.c
index 801b5c16789..c0457b8048c 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -6,7 +6,8 @@
 #include "repository.h"
 #include "commit.h"
 
-static int register_replace_ref(const char *refname,
+static int register_replace_ref(struct repository *r,
+				const char *refname,
 				const struct object_id *oid,
 				int flag, void *cb_data)
 {
@@ -25,7 +26,7 @@ static int register_replace_ref(const char *refname,
 	oidcpy(&repl_obj->replacement, oid);
 
 	/* Register new object */
-	if (oidmap_put(the_repository->objects->replace_map, repl_obj))
+	if (oidmap_put(r->objects->replace_map, repl_obj))
 		die("duplicate replace ref: %s", refname);
 
 	return 0;
@@ -40,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, NULL);
+	for_each_replace_repo_ref(r, register_replace_ref, NULL);
 }
 
 /* We allow "recursive" replacement. Only within reason, though */
-- 
2.18.0.345.g5c9ce644c3-goog
Previous: Duy Nguyen
Message 14 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.