@matheusbsbs / matheus-bagliano / commits / 84ee4ca10d
Fork 0

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 <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Han-Wen Nienhuys committed May 20, 2020 at 17:36 UTC 84ee4ca10d7f598542eb2c1ea2cdf6199f9bdee1
1 file changed +15 -3
refs/refs-internal.h
+15 -3
@@ -347,9 +347,13 @@ int is_empty_ref_iterator(struct ref_iterator *ref_iterator);
347 /*
348 * Return an iterator that goes over each reference in `refs` for
349 * 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.
357 */
358 struct ref_iterator *refs_ref_iterator_begin(
359 struct ref_store *refs,
@@ -438,6 +442,14 @@ void base_ref_iterator_free(struct ref_iterator *iter);
442
443 /* Virtual function declarations for ref_iterators: */
444
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 + */
453 typedef int ref_iterator_advance_fn(struct ref_iterator *ref_iterator);
454
455 typedef int ref_iterator_peel_fn(struct ref_iterator *ref_iterator,