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

Re: [PATCH v2 2/2] fetch: add cli option --default-only

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 5, 2024, 16:13 UTC
Message-ID
<xmqqa5pjpxm6.fsf@gitster.g>
In-Reply-To
<20240104222259.15659-2-dev@tb6.eu>
Tamino Bauknecht <dev@tb6.eu> writes:
> This option can be used to restore the default behavior of "git fetch"
> if the "fetch.all" config option is enabled.
> The flag cannot be used in combination with "--all" or explicit
> remote(s).

There is "--all" option that can be used to alter the behaviour of the command. This is OPT_BOOL(), and if you have

    [alias] f = fetch --all

you can say "git f --no-all" to countermand it from the command line, as it is equivalent to "git fetch --all --no-all" and the last one wins.

If you add "fetch.all" that makes the command behave as if it was given "--all" from the command line even when the user didn't, passing "--no-all" would be a lot more natural way to countermand it, no?

"git fetch" (no parameters) are omitting two kinds of stuff, i.e., where we fetch from (repository) and what we are fetching from there (refspec). You created a need to override the configured fetch source (aka fetch.all), and in order to countermand it, one way is to tell the command to "fetch from the default repository", but for that, an option that does not say "repository" anywhere is closing door for future evolution of the command. What if the next person (which could be you) invented a way to say what refspec to be used without specifying it from the command line, and needs to say "no, no, no, do not use the configured value, but just use the default"? In other words, "--default" will be met by a reaction "default of which one???".

Compared to that, I would think "--[no-]all" would be a lot simpler to understand.

The best part is that you do not have to add a new option. Just make sure the one specified from the command line, either --all or --no-all, will cause the command to ignore the configured fetch.all and you do not need to add anything new to the UI.

Previous: Eric SunshineNext: Tamino Bauknecht
Message 17 of 23 in “new config option "fetch.all"”
  1. Tamino BauknechtDec 18, 2023
  2. fetch: add new config option fetch.allTamino Bauknecht, Jan 4, 2024
  3. Taylor BlauJan 4, 2024
  4. Eric SunshineJan 4, 2024
  5. Junio C HamanoJan 4, 2024
  6. Tamino BauknechtJan 4, 2024
  7. Taylor BlauJan 4, 2024
  8. Junio C HamanoJan 4, 2024
  9. Tamino BauknechtJan 4, 2024
  10. Junio C HamanoJan 4, 2024
  11. fetch: add new config option fetch.allTamino Bauknecht, Jan 4, 2024
  12. Eric SunshineJan 4, 2024
  13. Eric SunshineJan 4, 2024
  14. 1/2 fetch: add new config option fetch.allTamino Bauknecht, Jan 4, 2024
  15. 2/2 fetch: add cli option --default-onlyTamino Bauknecht, Jan 4, 2024
  16. Eric SunshineJan 5, 2024
  17. Junio C HamanoJan 5, 2024
  18. fetch: add new config option fetch.allTamino Bauknecht, Jan 6, 2024
  19. Eric SunshineJan 6, 2024
  20. Eric SunshineJan 6, 2024
  21. Junio C HamanoJan 8, 2024
  22. fetch: add new config option fetch.allTamino Bauknecht, Jan 8, 2024
  23. Eric SunshineJan 5, 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.