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

[PATCH 12/17] refs: replace `refs_for_each_rawref()`

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 20, 2026, 08:24 UTC
Message-ID
<20260220-pks-refs-for-each-unification-v1-12-17170bd99de1@pks.im>
In-Reply-To
<20260220-pks-refs-for-each-unification-v1-0-17170bd99de1@pks.im>

Replace calls to `refs_for_each_rawref()` with the newly introduced `refs_for_each_ref_ext()` function.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/describe.c   |  7 +++++--
 builtin/fsck.c       |  7 +++++--
 fetch-pack.c         | 15 +++++++++++----
 refs.c               | 10 ++++------
 refs.h               |  1 -
 refs/files-backend.c |  7 +++++--
 6 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index abfe3525a5..bffeed13a3 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -641,6 +641,9 @@ int cmd_describe(int argc,
 		 const char *prefix,
 		 struct repository *repo UNUSED )
 {
+	struct refs_for_each_ref_options for_each_ref_opts = {
+		.flags = REFS_FOR_EACH_INCLUDE_BROKEN,
+	};
 	int contains = 0;
 	struct option options[] = {
 		OPT_BOOL(0, "contains",   &contains, N_("find the tag that comes after the commit")),
@@ -738,8 +741,8 @@ int cmd_describe(int argc,
 	}
 
 	hashmap_init(&names, commit_name_neq, NULL, 0);
-	refs_for_each_rawref(get_main_ref_store(the_repository), get_name,
-			     NULL);
+	refs_for_each_ref_ext(get_main_ref_store(the_repository),
+			      get_name, NULL, &for_each_ref_opts);
 	if (!hashmap_get_size(&names) && !always)
 		die(_("No names found, cannot describe anything."));
 
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 0512f78a87..24cdb657f5 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -598,6 +598,9 @@ static int fsck_handle_ref(const struct reference *ref, void *cb_data UNUSED)
 
 static void snapshot_refs(struct snapshot *snap, int argc, const char **argv)
 {
+	struct refs_for_each_ref_options opts = {
+		.flags = REFS_FOR_EACH_INCLUDE_BROKEN,
+	};
 	struct worktree **worktrees, **p;
 	const char *head_points_at;
 	struct object_id head_oid;
@@ -623,8 +626,8 @@ static void snapshot_refs(struct snapshot *snap, int argc, const char **argv)
 		return;
 	}
 
-	refs_for_each_rawref(get_main_ref_store(the_repository),
-			     snapshot_ref, snap);
+	refs_for_each_ref_ext(get_main_ref_store(the_repository),
+			      snapshot_ref, snap, &opts);
 
 	worktrees = get_worktrees();
 	for (p = worktrees; *p; p++) {
diff --git a/fetch-pack.c b/fetch-pack.c
index 40316c9a34..570caa03fa 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -292,11 +292,14 @@ static int next_flush(int stateless_rpc, int count)
 static void mark_tips(struct fetch_negotiator *negotiator,
 		      const struct oid_array *negotiation_tips)
 {
+	struct refs_for_each_ref_options opts = {
+		.flags = REFS_FOR_EACH_INCLUDE_BROKEN,
+	};
 	int i;
 
 	if (!negotiation_tips) {
-		refs_for_each_rawref(get_main_ref_store(the_repository),
-				     rev_list_insert_ref_oid, negotiator);
+		refs_for_each_ref_ext(get_main_ref_store(the_repository),
+				      rev_list_insert_ref_oid, negotiator, &opts);
 		return;
 	}
 
@@ -792,8 +795,12 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
 	 */
 	trace2_region_enter("fetch-pack", "mark_complete_local_refs", NULL);
 	if (!args->deepen) {
-		refs_for_each_rawref(get_main_ref_store(the_repository),
-				     mark_complete_oid, NULL);
+		struct refs_for_each_ref_options opts = {
+			.flags = REFS_FOR_EACH_INCLUDE_BROKEN,
+		};
+
+		refs_for_each_ref_ext(get_main_ref_store(the_repository),
+				      mark_complete_oid, NULL, &opts);
 		for_each_cached_alternate(NULL, mark_alternate_complete);
 		if (cutoff)
 			mark_recent_complete_commits(args, cutoff);
diff --git a/refs.c b/refs.c
index b42a1bfa3f..5739804870 100644
--- a/refs.c
+++ b/refs.c
@@ -524,7 +524,10 @@ void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp,
 		.indent = indent,
 		.dry_run = dry_run,
 	};
-	refs_for_each_rawref(refs, warn_if_dangling_symref, &data);
+	struct refs_for_each_ref_options opts = {
+		.flags = REFS_FOR_EACH_INCLUDE_BROKEN,
+	};
+	refs_for_each_ref_ext(refs, warn_if_dangling_symref, &data, &opts);
 }
 
 int refs_for_each_tag_ref(struct ref_store *refs, refs_for_each_cb cb, void *cb_data)
@@ -1969,11 +1972,6 @@ int refs_for_each_namespaced_ref(struct ref_store *refs,
 	return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
 }
 
-int refs_for_each_rawref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data)
-{
-	return refs_for_each_rawref_in(refs, "", fn, cb_data);
-}
-
 int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix,
 			    refs_for_each_cb cb, void *cb_data)
 {
diff --git a/refs.h b/refs.h
index c9f8d3e6cb..7a0c9c3693 100644
--- a/refs.h
+++ b/refs.h
@@ -542,7 +542,6 @@ int refs_for_each_namespaced_ref(struct ref_store *refs,
 				 refs_for_each_cb fn, void *cb_data);
 
 /* can be used to learn about broken ref and symref */
-int refs_for_each_rawref(struct ref_store *refs, refs_for_each_cb fn, void *cb_data);
 int refs_for_each_rawref_in(struct ref_store *refs, const char *prefix,
 			    refs_for_each_cb fn, void *cb_data);
 
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 6c98e14414..ab96760781 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -3149,6 +3149,9 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
 					    struct ref_transaction *transaction,
 					    struct strbuf *err)
 {
+	struct refs_for_each_ref_options opts = {
+		.flags = REFS_FOR_EACH_INCLUDE_BROKEN,
+	};
 	size_t i;
 	int ret = 0;
 	struct string_list affected_refnames = STRING_LIST_INIT_NODUP;
@@ -3173,8 +3176,8 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
 	 * so here we really only check that none of the references
 	 * that we are creating already exists.
 	 */
-	if (refs_for_each_rawref(&refs->base, ref_present,
-				 &transaction->refnames))
+	if (refs_for_each_ref_ext(&refs->base, ref_present,
+				  &transaction->refnames, &opts))
 		BUG("initial ref transaction called with existing refs");
 
 	packed_transaction = ref_store_transaction_begin(refs->packed_ref_store,
-- 
2.53.0.414.gf7e9f6c205.dirty
Previous: Karthik NayakNext: Patrick Steinhardt
Message 28 of 34 in “refs: unify `refs_for_each_*()` functions”
  1. 00/17 refs: unify `refs_for_each_*()` functionsPatrick Steinhardt, Feb 20, 2026
  2. 01/17 refs: move `refs_head_ref_namespaced()`Patrick Steinhardt, Feb 20, 2026
  3. Karthik NayakFeb 23, 2026
  4. Patrick SteinhardtFeb 23, 2026
  5. 02/17 refs: move `do_for_each_ref_flags` further upPatrick Steinhardt, Feb 20, 2026
  6. 03/17 refs: rename `do_for_each_ref_flags`Patrick Steinhardt, Feb 20, 2026
  7. 04/17 refs: rename `each_ref_fn`Patrick Steinhardt, Feb 20, 2026
  8. Karthik NayakFeb 23, 2026
  9. 05/17 refs: remove unused `refs_for_each_include_root_ref()`Patrick Steinhardt, Feb 20, 2026
  10. Oswald BuddenhagenFeb 20, 2026
  11. Patrick SteinhardtFeb 20, 2026
  12. 06/17 refs: introduce `refs_for_each_ref_ext`Patrick Steinhardt, Feb 20, 2026
  13. Karthik NayakFeb 23, 2026
  14. 07/17 refs: speed up `refs_for_each_glob_ref_in()`Patrick Steinhardt, Feb 20, 2026
  15. Karthik NayakFeb 23, 2026
  16. Patrick SteinhardtFeb 23, 2026
  17. 08/17 refs: generalize `refs_for_each_namespaced_ref()`Patrick Steinhardt, Feb 20, 2026
  18. Karthik NayakFeb 23, 2026
  19. Patrick SteinhardtFeb 23, 2026
  20. 09/17 refs: generalize `refs_for_each_fullref_in_prefixes()`Patrick Steinhardt, Feb 20, 2026
  21. Karthik NayakFeb 23, 2026
  22. 10/17 refs: improve verification for-each-ref optionsPatrick Steinhardt, Feb 20, 2026
  23. Karthik NayakFeb 23, 2026
  24. 11/17 refs: replace `refs_for_each_ref_in()`Patrick Steinhardt, Feb 20, 2026
  25. Karthik NayakFeb 23, 2026
  26. Patrick SteinhardtFeb 23, 2026
  27. Karthik NayakFeb 23, 2026
  28. 12/17 refs: replace `refs_for_each_rawref()`Patrick Steinhardt, Feb 20, 2026
  29. 13/17 refs: replace `refs_for_each_rawref_in()`Patrick Steinhardt, Feb 20, 2026
  30. 14/17 refs: replace `refs_for_each_glob_ref_in()`Patrick Steinhardt, Feb 20, 2026
  31. 15/17 refs: replace `refs_for_each_glob_ref()`Patrick Steinhardt, Feb 20, 2026
  32. 16/17 refs: replace `refs_for_each_namespaced_ref()`Patrick Steinhardt, Feb 20, 2026
  33. 17/17 refs: replace `refs_for_each_fullref_in()`Patrick Steinhardt, Feb 20, 2026
  34. Karthik NayakFeb 23, 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.