Skip to content

Commit 84ee4ca

Browse files
hanwengitster
authored andcommitted
refs: improve documentation for ref iterator
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cdb73ca commit 84ee4ca

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

refs/refs-internal.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,13 @@ int is_empty_ref_iterator(struct ref_iterator *ref_iterator);
347347
/*
348348
* Return an iterator that goes over each reference in `refs` for
349349
* which the refname begins with prefix. If trim is non-zero, then
350-
* trim that many characters off the beginning of each refname. flags
351-
* can be DO_FOR_EACH_INCLUDE_BROKEN to include broken references in
352-
* the iteration. The output is ordered by refname.
350+
* trim that many characters off the beginning of each refname.
351+
* The output is ordered by refname. The following flags are supported:
352+
*
353+
* DO_FOR_EACH_INCLUDE_BROKEN: include broken references in
354+
* the iteration.
355+
*
356+
* DO_FOR_EACH_PER_WORKTREE_ONLY: only produce REF_TYPE_PER_WORKTREE refs.
353357
*/
354358
struct ref_iterator *refs_ref_iterator_begin(
355359
struct ref_store *refs,
@@ -438,6 +442,14 @@ void base_ref_iterator_free(struct ref_iterator *iter);
438442

439443
/* Virtual function declarations for ref_iterators: */
440444

445+
/*
446+
* backend-specific implementation of ref_iterator_advance. For symrefs, the
447+
* function should set REF_ISSYMREF, and it should also dereference the symref
448+
* to provide the OID referent. If DO_FOR_EACH_INCLUDE_BROKEN is set, symrefs
449+
* with non-existent referents and refs pointing to non-existent object names
450+
* should also be returned. If DO_FOR_EACH_PER_WORKTREE_ONLY, only
451+
* REF_TYPE_PER_WORKTREE refs should be returned.
452+
*/
441453
typedef int ref_iterator_advance_fn(struct ref_iterator *ref_iterator);
442454

443455
typedef int ref_iterator_peel_fn(struct ref_iterator *ref_iterator,

0 commit comments

Comments
 (0)