245
/* We allow "recursive" symbolic refs. Only within reason, though */
246
#define SYMREF_MAXDEPTH 5
247
248
-/* Include broken references in a do_for_each_ref*() iteration: */
249
-#define DO_FOR_EACH_INCLUDE_BROKEN 0x01
250
-
248
/*
252
- * Only include per-worktree refs in a do_for_each_ref*() iteration.
253
- * Normally this will be used with a files ref_store, since that's
254
- * where all reference backends will presumably store their
255
- * per-worktree refs.
249
+ * These flags are passed to refs_ref_iterator_begin() (and do_for_each_ref(),
250
+ * which feeds it).
251
*/
257
-#define DO_FOR_EACH_PER_WORKTREE_ONLY 0x02
252
+enum do_for_each_ref_flags {
253
+ /*
254
+ * Include broken references in a do_for_each_ref*() iteration, which
255
+ * would normally be omitted. This includes both refs that point to
256
+ * missing objects (a true repository corruption), ones with illegal
257
+ * names (which we prefer not to expose to callers), as well as
258
+ * dangling symbolic refs (i.e., those that point to a non-existent
259
+ * ref; this is not a corruption, but as they have no valid oid, we
260
+ * omit them from normal iteration results).
261
+ */
262
+ DO_FOR_EACH_INCLUDE_BROKEN = (1 << 0),
263
+
264
+ /*
265
+ * Only include per-worktree refs in a do_for_each_ref*() iteration.
266
+ * Normally this will be used with a files ref_store, since that's
267
+ * where all reference backends will presumably store their
268
+ * per-worktree refs.
269
+ */
270
+ DO_FOR_EACH_PER_WORKTREE_ONLY = (1 << 1),
271
+};
272
273
/*
274
* Reference iterators
371
* Return an iterator that goes over each reference in `refs` for
372
* which the refname begins with prefix. If trim is non-zero, then
373
* trim that many characters off the beginning of each refname.
360
- * The output is ordered by refname. The following flags are supported:
361
- *
362
- * DO_FOR_EACH_INCLUDE_BROKEN: include broken references in
363
- * the iteration.
364
- *
365
- * DO_FOR_EACH_PER_WORKTREE_ONLY: only produce REF_TYPE_PER_WORKTREE refs.
374
+ * The output is ordered by refname.
375
*/
376
struct ref_iterator *refs_ref_iterator_begin(
377
struct ref_store *refs,
369
- const char *prefix, int trim, int flags);
378
+ const char *prefix, int trim,
379
+ enum do_for_each_ref_flags flags);
380
381
/*
382
* A callback function used to instruct merge_ref_iterator how to
464
/*
465
* backend-specific implementation of ref_iterator_advance. For symrefs, the
466
* function should set REF_ISSYMREF, and it should also dereference the symref
457
- * to provide the OID referent. If DO_FOR_EACH_INCLUDE_BROKEN is set, symrefs
458
- * with non-existent referents and refs pointing to non-existent object names
459
- * should also be returned. If DO_FOR_EACH_PER_WORKTREE_ONLY, only
460
- * REF_TYPE_PER_WORKTREE refs should be returned.
467
+ * to provide the OID referent. It should respect do_for_each_ref_flags
468
+ * that were passed to refs_ref_iterator_begin().
469
*/
470
typedef int ref_iterator_advance_fn(struct ref_iterator *ref_iterator);
471