Web lists-archives.com

[PATCH 054/194] replace-object: add repository argument to register_replace_ref




Unlike the other conversions this just takes the repository as the cb_data.

NEEDSWORK: callback interface doesn't supply a repository argument, so
we have to supply it ourselves as cb_data. It would be nicer to update
the callback interface in for_each_replace_ref to pass on the
repository at the same time as it gets a repository argument.

Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
---
 replace-object.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/replace-object.c b/replace-object.c
index 1479530d34..8d3e0a30fb 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -52,6 +52,8 @@ static int register_replace_ref(const char *refname,
 				const struct object_id *oid,
 				int flag, void *cb_data)
 {
+	struct repository *r = cb_data;
+
 	/* Get sha1 from refname */
 	const char *slash = strrchr(refname, '/');
 	const char *hash = slash ? slash + 1 : refname;
@@ -67,6 +69,7 @@ static int register_replace_ref(const char *refname,
 	hashcpy(repl_obj->replacement, oid->hash);
 
 	/* Register new object */
+	(void)r;
 	if (register_replace_object(the_repository, repl_obj, 1))
 		die("duplicate replace ref: %s", refname);
 
@@ -78,7 +81,7 @@ static void prepare_replace_object(void)
 	if (the_repository->objects.replacements.prepared)
 		return;
 
-	for_each_replace_ref(the_repository, register_replace_ref, NULL);
+	for_each_replace_ref(the_repository, register_replace_ref, the_repository);
 	the_repository->objects.replacements.prepared = 1;
 }
 
-- 
2.15.1.433.g936d1b9894.dirty