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

Re: [PATCH v6 08/10] submodule: add a helper to check if it is safe to write to .gitmodules

From
Antonio Ospite <ao2@ao2.it>
Date
Oct 8, 2018, 12:37 UTC
Message-ID
<20181008143709.dfcc845ab393c9caea66035e@ao2.it>
In-Reply-To
<xmqq36tiwsh7.fsf@gitster-ct.c.googlers.com>

On Sun, 07 Oct 2018 08:44:20 +0900 Junio C Hamano <gitster@pobox.com> wrote:

Show 21 quoted lines
> Stefan Beller <sbeller@google.com> writes:
> 
> >>  static int module_config(int argc, const char **argv, const char *prefix)
> >>  {
> >> +       enum {
> >> +               CHECK_WRITEABLE = 1
> >> +       } command = 0;
> >
> > Can we have the default named? Then we would only use states
> > from within the enum?
> 
> Why?  Do we use a half-intelligent "switch () { case ...: ... }"
> checker that would otherwise complain if we handled "case 0" in such
> a switch statement, or something like that?
> 
> Are we going to gain a lot more enum members, by the way?  At this
> point, this looks more like a
> 
> 	unsigned check_writable = 0; /* default is not to check */
> 
> to me.
Hi,

the CHECK_WRITEABLE operation is alternative to the get/set ones, not an addition, so I can see the rationale behind Stefan's suggestion: either have named enums members for all command "modes" or for none of them; however other users of enum+OPT_CMDMODE seems to think like the enum is for commands passed as *options* and the unnamed default is for actions derived from *arguments*. I don't have a strong opinion on this matter, tho, so just tell me what you prefer and I'll do it for v7.

Using an enum was to have a more explicit syntax in case other commands were going to be added in the future (I imagine "--stage" or "--list-all" as possible additions), and does not affect the generated code, so I though it was worth it.

Anyways, these are really details, let's concentrate on patches 9 and 10 which deserve much more attention. :)

Thanks you,
   Antonio
-- 
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
Previous: Junio C HamanoNext: Antonio Ospite
Message 19 of 23 in “Make submodules work if .gitmodules is not checked out”
  1. 00/10 Make submodules work if .gitmodules is not checked outAntonio Ospite, Oct 5, 2018
  2. 03/10 t7411: merge tests 5 and 6Antonio Ospite, Oct 5, 2018
  3. 09/10 submodule: support reading .gitmodules when it's not in the working treeAntonio Ospite, Oct 5, 2018
  4. Stefan BellerOct 8, 2018
  5. Antonio OspiteOct 10, 2018
  6. Stefan BellerOct 10, 2018
  7. Junio C HamanoOct 9, 2018
  8. Junio C HamanoOct 9, 2018
  9. 04/10 t7411: be nicer to future tests and really clean things upAntonio Ospite, Oct 5, 2018
  10. 10/10 t/helper: add test-submodule-nested-repo-configAntonio Ospite, Oct 5, 2018
  11. 02/10 submodule: factor out a config_set_in_gitmodules_file_gently functionAntonio Ospite, Oct 5, 2018
  12. 01/10 submodule: add a print_config_from_gitmodules() helperAntonio Ospite, Oct 5, 2018
  13. 06/10 submodule: use the 'submodule--helper config' commandAntonio Ospite, Oct 5, 2018
  14. 05/10 submodule--helper: add a new 'config' subcommandAntonio Ospite, Oct 5, 2018
  15. 08/10 submodule: add a helper to check if it is safe to write to .gitmodulesAntonio Ospite, Oct 5, 2018
  16. Stefan BellerOct 5, 2018
  17. Antonio OspiteOct 6, 2018
  18. Junio C HamanoOct 6, 2018
  19. Antonio OspiteOct 8, 2018
  20. 07/10 t7506: clean up .gitmodules properly before setting up new scenarioAntonio Ospite, Oct 5, 2018
  21. Antonio OspiteOct 6, 2018
  22. Junio C HamanoOct 25, 2018
  23. Antonio OspiteOct 25, 2018

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.