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

[PATCH 3/6] refs: improve documentation for ref iterator

From
Han-Wen Nienhuys via GitGitGadget <gitgitgadget@gmail.com>
Date
May 20, 2020, 17:36 UTC
Message-ID
<2a0f428a91060e0014086d0018d6887538299143.1589996173.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.638.git.1589996173.gitgitgadget@gmail.com>
From: Han-Wen Nienhuys <hanwen@google.com>

Document some of the flag options in refs_ref_iterator_begin, and explain how ref_iterator_advance_fn should handle them.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 refs/refs-internal.h | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index ff2436c0fb7..4271362d264 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -347,9 +347,13 @@ int is_empty_ref_iterator(struct ref_iterator *ref_iterator);
 /*
  * Return an iterator that goes over each reference in `refs` for
  * which the refname begins with prefix. If trim is non-zero, then
- * trim that many characters off the beginning of each refname. flags
- * can be DO_FOR_EACH_INCLUDE_BROKEN to include broken references in
- * the iteration. The output is ordered by refname.
+ * trim that many characters off the beginning of each refname.
+ * The output is ordered by refname. The following flags are supported:
+ *
+ * DO_FOR_EACH_INCLUDE_BROKEN: include broken references in
+ *         the iteration.
+ *
+ * DO_FOR_EACH_PER_WORKTREE_ONLY: only produce REF_TYPE_PER_WORKTREE refs.
  */
 struct ref_iterator *refs_ref_iterator_begin(
 		struct ref_store *refs,
@@ -438,6 +442,14 @@ void base_ref_iterator_free(struct ref_iterator *iter);
 
 /* Virtual function declarations for ref_iterators: */
 
+/*
+ * backend-specific implementation of ref_iterator_advance. For symrefs, the
+ * function should set REF_ISSYMREF, and it should also dereference the symref
+ * to provide the OID referent. If DO_FOR_EACH_INCLUDE_BROKEN is set, symrefs
+ * with non-existent referents and refs pointing to non-existent object names
+ * should also be returned. If DO_FOR_EACH_PER_WORKTREE_ONLY, only
+ * REF_TYPE_PER_WORKTREE refs should be returned.
+ */
 typedef int ref_iterator_advance_fn(struct ref_iterator *ref_iterator);
 
 typedef int ref_iterator_peel_fn(struct ref_iterator *ref_iterator,
-- 
gitgitgadget
Previous: Han-Wen Nienhuys via GitGitGadgetNext: Jonathan Nieder via GitGitGadget
Message 4 of 8 in “Refs cleanup”
  1. 0/6 Refs cleanupHan-Wen Nienhuys via GitGitGadget, May 20, 2020
  2. 1/6 refs.h: clarify reflog iteration orderHan-Wen Nienhuys via GitGitGadget, May 20, 2020
  3. 2/6 t: use update-ref and show-ref to reading/writing refsHan-Wen Nienhuys via GitGitGadget, May 20, 2020
  4. 3/6 refs: improve documentation for ref iteratorHan-Wen Nienhuys via GitGitGadget, May 20, 2020
  5. 4/6 reftable: file format documentationJonathan Nieder via GitGitGadget, May 20, 2020
  6. 6/6 reftable: define version 2 of the spec to accomodate SHA256Han-Wen Nienhuys via GitGitGadget, May 20, 2020
  7. 5/6 reftable: clarify how empty tables should be writtenHan-Wen Nienhuys via GitGitGadget, May 20, 2020
  8. Junio C HamanoMay 20, 2020

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.