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

Re: [PATCH v3] builtin/revert.c: refactor using an enum for cmd-action

From
Michael Lohmann <mi.al.lohmann@gmail.com>
Date
Jan 12, 2024, 19:33 UTC
Message-ID
<20240112193359.2332-1-mi.al.lohmann@gmail.com>
In-Reply-To
<xmqqil3ybets.fsf@gitster.g>
On 12. Jan 2024, at 19:13, Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> > But your way of seeing it also makes sense to me. I think I just find
> > the "START" name jarring because we do not use that word elsewhere to
> > describe the action.
> 
> Thanks.  I forgot to say that I share the same feeling, both about
> "NONE could mean no-op" (but then seriously why would anybody sane
> want that?) and "START is not how we spell these things".  I can see
> how DEFAULT could make sense, but if somebody picked DEFAULT between
> two sensible choices NONE and DEFAULT here, especially if they claim
> that they started this enum to mimick what is done in another place,
> and after they were told that the other place they are imitating
> follows the convention of using NONE for "nothing specified, so use
> default", I would have to say that they are trying to be different
> for the sake of being different, which is not a good sign.  I'd want
> our contributors to be original where being original matters more.

I am sorry to have left this feeling in you. It was not my intention to be original, but I just did not understand the reason for the other name. If I wanted to be "sneaky" and wasn't truly open for a discussion I would not have mentioned that it is different in the other file. I don't try to be original for the sake of it, but yes indeed if I have a hard time understanding some reasoning, in my day job it is my role to ask these. But I think I am indeed questioning a bit too much here. Sorry for that! You as the project lead constantly have to do the same and I am in awe as how you handle it.

I am sorry that this discussion did get out of hand. Especially since this patch does not even introduce a feature, but is only a refactoring of an already perfectly fine codebase. My only intention was to align builtin/refactor.c a bit more to builtin/rebase.c but the current state is 100% good as is, so I think we should just drop this discussion.

Show 13 quoted lines
> > + if (cmd != ACTION_START)
> > 
> > Likewise here I'd probably leave this as "if (cmd)".
> 
> I 100% agree with the suggestion to explicitly define something to
> be 0 when we are going to use it for its Boolean value.  So an
> alternative would be to treat all ACTION_* enum values the same, and
> not define the first one explicitly to 0.  
> 
> Especially in the context of a patch that wants to turn if/elseif
> cascades to switch, I would suspect that the latter, as switch/case
> does not special case the falsehood among other possible values of
> integer type, might be easier to maintain in the longer term.

That is indeed what v4 of the patch did that I prepared half a day ago and just did not have the time to properly check again before I submit it. It also tackles the other issues you mentioned, but my feeling is that the current state is good as it is with the characters and so we should just drop this discussion.

Sorry to have caused such a stir and that I took so much of all of your valuable time! I for myself have learned a great deal from all of you and your interactions, so thank you!

Michael Lohmann
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 11 in “builtin/revert.c: refactor using an enum for cmd-action”
  1. builtin/revert.c: refactor using an enum for cmd-actionMichael Lohmann, Jan 11, 2024
  2. Phillip WoodJan 11, 2024
  3. builtin/revert.c: refactor using an enum for cmd-actionMichael Lohmann, Jan 11, 2024
  4. Junio C HamanoJan 11, 2024
  5. builtin/revert.c: refactor using an enum for cmd-actionMichael Lohmann, Jan 11, 2024
  6. Junio C HamanoJan 11, 2024
  7. Junio C HamanoJan 12, 2024
  8. Jeff KingJan 12, 2024
  9. Junio C HamanoJan 12, 2024
  10. Michael LohmannJan 12, 2024
  11. Junio C HamanoJan 11, 2024

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.