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

[Outreachy PATCH v3 1/2] remote: add repo_for_each_remote()

From
OAOkhuomon Ajayi <okhuomonajayi54@gmail.com>
Date
Oct 23, 2026, 21:15 UTC
Message-ID
<20261023211533.73433-2-okhuomonajayi54@gmail.com>
In-Reply-To
<20261023211533.73433-1-okhuomonajayi54@gmail.com>
for_each_remote() always reads the remotes of the_repository.

Add repo_for_each_remote(), which takes a repository, and turn for_each_remote() into a wrapper that passes the_repository. Callers that are given a repository, such as unique_tracking_name() in the next patch, can then use the remotes of that repository.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
 remote.c | 14 ++++++++++----
 remote.h |  2 ++
 2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/remote.c b/remote.c
index 71170f36a9..d18f39d19a 100644
--- a/remote.c
+++ b/remote.c
@@ -869,14 +869,15 @@ int remote_is_configured(struct remote *remote, int in_repo)
 	return !!remote->origin;
 }
 
-int for_each_remote(each_remote_fn fn, void *priv)
+int repo_for_each_remote(struct repository *repo,
+			 each_remote_fn fn, void *priv)
 {
 	int i, result = 0;
-	read_config(the_repository, 0);
-	for (i = 0; i < the_repository->remote_state->remotes_nr && !result;
+	read_config(repo, 0);
+	for (i = 0; i < repo->remote_state->remotes_nr && !result;
 	     i++) {
 		struct remote *remote =
-			the_repository->remote_state->remotes[i];
+			repo->remote_state->remotes[i];
 		if (!remote)
 			continue;
 		result = fn(remote, priv);
@@ -884,6 +885,11 @@ int for_each_remote(each_remote_fn fn, void *priv)
 	return result;
 }
 
+int for_each_remote(each_remote_fn fn, void *priv)
+{
+	return repo_for_each_remote(the_repository, fn, priv);
+}
+
 static void handle_duplicate(struct ref *ref1, struct ref *ref2)
 {
 	if (strcmp(ref1->name, ref2->name)) {
diff --git a/remote.h b/remote.h
index cca02033b9..2a0bf416d9 100644
--- a/remote.h
+++ b/remote.h
@@ -140,6 +140,8 @@ int remote_is_configured(struct remote *remote, int in_repo);
 typedef int each_remote_fn(struct remote *remote, void *priv);
 
 /* iterate through struct remotes */
+int repo_for_each_remote(struct repository *repo,
+			 each_remote_fn fn, void *priv);
 int for_each_remote(each_remote_fn fn, void *priv);
 
 int remote_has_url(struct remote *remote, const char *url);
-- 
2.56.0
Previous: Okhuomon AjayiNext: Christian Couder
Message 9 of 14 in “checkout: use repository parameter in unique_tracking_name”
  1. checkout: use repository parameter in unique_tracking_nameOkhuomon Ajayi, Oct 17, 2026
  2. Usman AkinyemiOct 22, 2026
  3. Okhuomon AjayiOct 22, 2026
  4. checkout: pass the repository to unique_tracking_name()Okhuomon Ajayi, Oct 22, 2026
  5. Junio C HamanoOct 22, 2026
  6. Junio C HamanoOct 22, 2026
  7. Okhuomon AjayiOct 22, 2026
  8. 0/2 checkout: make unique_tracking_name() use the given repositoryOkhuomon Ajayi, Oct 23, 2026
  9. 1/2 remote: add repo_for_each_remote()Okhuomon Ajayi, Oct 23, 2026
  10. Christian CouderNov 3, 2026
  11. 2/2 checkout: pass the repository to unique_tracking_name()Okhuomon Ajayi, Oct 23, 2026
  12. 0/2 checkout: make unique_tracking_name() use the given repositoryOkhuomon Ajayi, Nov 4, 2026
  13. 1/2 remote: add repo_for_each_remote()Okhuomon Ajayi, Nov 4, 2026
  14. 2/2 checkout: pass the repository to unique_tracking_name()Okhuomon Ajayi, Nov 4, 2026

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.