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

Re: [PATCH 3/5] convert: Use the enum constant SAFE_CRLF_FALSE.

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 1, 2010, 19:53 UTC
Message-ID
<7vaatnosop.fsf@alter.siamese.dyndns.org>
In-Reply-To
<74ce7980eb1fe629a651433ca9f1662f26495ce9.1269860022.git.grubba@grubba.org>
"Henrik Grubbström (Grubba)"  <grubba@grubba.org> writes:
> A few places used plain zeros as the last argument to convert_to_git,
> instead of the corresponding enum constant.
I have a feeling that you are fixing a wrong problem.

If anything, I personally think that the original that passes 0 makes it easier to read the callers, and I suspect that the primary reason why it is so is because SAFE_CRLF_FALSE is grossly misnamed. X_FALSE makes the reader wonder "perhaps I can change it to X_TRUE and make something interesting happen?" but there of course is no SAFE_CRLF_TRUE.

Look at the callee that _ought_ to use the enum constant but doesn't:
    static void check_safe_crlf(const char *path, int action,
                                struct text_stat *stats, enum safe_crlf checksafe)
    {
            if (!checksafe)
                    return;
    ...

The "checksafe" is used to specify "what should be done if it turns out to be unsafe after inspection", and passing 0 is "won't do anything, so there is no point to even check". Both callers and the callee _know_ that 0 means "don't bother", and thus this callee doesn't bother.

If the constant were renamed from SAFE_CRLF_FALSE to something a bit more sensible (perhaps SAFE_CRLF_NOWARN? SAFE_CRLF_NOOP?), then it might make sense to replace these 0 with symbolic constants and argue that such a change makes the code easier to read.

Previous: Stephen R. van den BergNext: Stephen R. van den Berg
Message 12 of 14 in “ident attribute related patches (resend w/ testsuite v3)”
  1. 0/5 ident attribute related patches (resend w/ testsuite v3)Henrik Grubbström (Grubba), Mar 29, 2010
  2. 1/5 convert: Safer handling of $Id$ contraction.Henrik Grubbström (Grubba), Mar 29, 2010
  3. 2/5 convert: Keep foreign $Id$ on checkout.Henrik Grubbström (Grubba), Mar 29, 2010
  4. 3/5 convert: Use the enum constant SAFE_CRLF_FALSE.Henrik Grubbström (Grubba), Mar 29, 2010
  5. 4/5 convert: Inhibit contraction of foreign $Id$ during stats.Henrik Grubbström (Grubba), Mar 29, 2010
  6. 5/5 convert: Added core.refilteronadd feature.Henrik Grubbström (Grubba), Mar 29, 2010
  7. Stephen R. van den BergMar 29, 2010
  8. Stephen R. van den BergMar 29, 2010
  9. Junio C HamanoApr 1, 2010
  10. Henrik GrubbströmApr 6, 2010
  11. Stephen R. van den BergMar 29, 2010
  12. Junio C HamanoApr 1, 2010
  13. Stephen R. van den BergMar 29, 2010
  14. Stephen R. van den BergMar 29, 2010

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.