summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2021-09-24 18:39:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-27 19:36:45 (GMT)
commit9aab952e855be1a567d4d0585afbdbde624e274f (patch)
tree03d2fd8554577fc92a1f7e53f036b48316baf17f /refs.c
parentbf708add2eaf37d53fa8a908b5d8772806c54d1b (diff)
downloadgit-9aab952e855be1a567d4d0585afbdbde624e274f.zip
git-9aab952e855be1a567d4d0585afbdbde624e274f.tar.gz
git-9aab952e855be1a567d4d0585afbdbde624e274f.tar.bz2
refs-internal.h: reorganize DO_FOR_EACH_* flag documentation
The documentation for the DO_FOR_EACH_* flags is sprinkled over the refs-internal.h file. We define the two flags in one spot, and then describe them in more detail far away from there, in the definitions of refs_ref_iterator_begin() and ref_iterator_advance_fn(). Let's try to organize this a bit better: - convert the #defines to an enum. This makes it clear that they are related, and that the enum shows the complete set of flags. - combine all descriptions for each flag in a single spot, next to the flag's definition - use the enum rather than a bare int for functions which take the flags. This helps readers realize which flags can be used. - clarify the mention of flags for ref_iterator_advance_fn(). It does not take flags itself, but is meant to depend on ones set up earlier. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/refs.c b/refs.c
index 8b9f7c3..c28bd6a 100644
--- a/refs.c
+++ b/refs.c
@@ -1413,7 +1413,8 @@ int head_ref(each_ref_fn fn, void *cb_data)
struct ref_iterator *refs_ref_iterator_begin(
struct ref_store *refs,
- const char *prefix, int trim, int flags)
+ const char *prefix, int trim,
+ enum do_for_each_ref_flags flags)
{
struct ref_iterator *iter;
@@ -1479,7 +1480,8 @@ static int do_for_each_ref_helper(struct repository *r,
}
static int do_for_each_ref(struct ref_store *refs, const char *prefix,
- each_ref_fn fn, int trim, int flags, void *cb_data)
+ each_ref_fn fn, int trim,
+ enum do_for_each_ref_flags flags, void *cb_data)
{
struct ref_iterator *iter;
struct do_for_each_ref_help hp = { fn, cb_data };
@@ -1516,7 +1518,7 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data, unsigned int broken)
{
- unsigned int flag = 0;
+ enum do_for_each_ref_flags flag = 0;
if (broken)
flag = DO_FOR_EACH_INCLUDE_BROKEN;
@@ -1528,7 +1530,7 @@ int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
each_ref_fn fn, void *cb_data,
unsigned int broken)
{
- unsigned int flag = 0;
+ enum do_for_each_ref_flags flag = 0;
if (broken)
flag = DO_FOR_EACH_INCLUDE_BROKEN;