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

flags types/names (was: ps/avoid-unnecessary-hook-invocation-with-packed-refs)

From
Han-Wen Nienhuys <hanwen@google.com>
Date
Jan 31, 2022, 09:50 UTC
Message-ID
<CAFQ2z_M_SXENMU6Y3Evrz9-G_+pqjd-zPQiZjnA_y2hvb+Egkw@mail.gmail.com>
In-Reply-To
<xmqqilu3woj2.fsf@gitster.g>
On Fri, Jan 28, 2022 at 10:15 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 6 quoted lines
> > knowledge there shouldn't be any more issues my series. The only
> > question that remains open is Han-Wen's [2], but as I replied I'm not
> > sure we actually need to adjust documentation of the flags given that we
> > already do explicitly say how we pass through flags in all cases.
>
> I'll let Han-Wen answer this first.

I've recently been working on ref iteration, and it's a pretty confusing area, because the iterator has flags (should it skip broken refs, etc.) , and the refs themselves have flags (is the ref broken), and some code must manipulate both in the same function: the ref iterator structure has a member `flags`, but it's not the flags passed to ref_iterator_begin(). In code, this all looks like `flags`, the compiler does no type checking, and it is often hard to see which bit field goes where. Here we have another thing called `flags` added in a context where the meaning of the flags can be ambiguous.

If you want to add another instance, that in itself seems fine, because there is plenty of precedent across the code for this.

My questions:
* am I the only one who struggles with the different flavor of `flags` ?
* if no, what should be done about this? Maybe
  typedef unsigned int ref_flags;
  #define REF_IS_SYMREF 0x1
  char *refs_resolve_ref_unsafe(const char *refname, ref_flags *flags, ... );
or
  typedef enum ref_flags {
     REF_IS_SYMREF = 0x1,
  };
  char *refs_resolve_ref_unsafe(const char *refname, enum ref_flags
*flags, ... );

A somewhat related gripe is that some code uses `int flags` and other code uses `unsigned flags`. It would be great to standardize this.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 16 in “What's cooking in git.git (Jan 2022, #07; Mon, 24)”
  1. Junio C HamanoJan 24, 2022
  2. Submodule UX overhaul update (was: What's cooking in git.git (Jan 2022, #07; Mon, 24))Emily Shaffer, Jan 25, 2022
  3. Ævar Arnfjörð BjarmasonJan 26, 2022
  4. Emily ShafferJan 26, 2022
  5. Kaartic SivaraamJan 26, 2022
  6. Atharva RaykarJan 26, 2022
  7. Emily ShafferJan 26, 2022
  8. Glen ChooJan 26, 2022
  9. ps/avoid-unnecessary-hook-invocation-with-packed-refs (Was: Re: What's cooking in git.git (Jan 2022, #07; Mon, 24))Patrick Steinhardt, Jan 28, 2022
  10. Junio C HamanoJan 28, 2022
  11. flags types/names (was: ps/avoid-unnecessary-hook-invocation-with-packed-refs)Han-Wen Nienhuys, Jan 31, 2022
  12. Junio C HamanoJan 31, 2022
  13. brian m. carlsonJan 28, 2022
  14. Junio C HamanoFeb 4, 2022
  15. René ScharfeFeb 4, 2022
  16. ab/auto-detect-zlib-compress2 (was: What's cooking in git.git (Jan 2022, #07; Mon, 24))Ævar Arnfjörð Bjarmason, Feb 2, 2022

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.