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

RFC proposal: set git defaults options from config

From
MGMichael J Gruber <drmicha@warpmail.net>
Date
May 12, 2011, 14:35 UTC
Message-ID
<4DCBF01F.9040009@warpmail.net>
In-Reply-To
<20110512082210.GA16813@sigill.intra.peff.net>

Mechanism =========

I propose the following mechanism for setting default command line options from the config:

options.<cmd> = <value>

is a "multivar" in git-config speak, i.e. it can appear multiple times. When running "git <cmd> <opts>", our wrapper executes

git <cmd> <values> <opt>
where <values> is determined by the following rule in pseudocode:
if $GIT_OPTIONS_<cmd> is unset:
  <values> := empty
else:
  for <value> in $(git config --get-all options.cmd):
    if <value> matches the regexp in $GIT_OPTIONS_<CMD>:
      append <value> to <values>

Examples ========

* By default, no options can be overriden from config (other than those
which have config vars already, of course).
* A script which wants to protect options "foo" and "bar" of "cmd" from
being set by config sets GIT_OPTIONS_CMD="!(foo|bar)".
* A script which wants to allow overriding options "foo" and "bar" of
"cmd" by config (but nothing else) sets GIT_OPTIONS_CMD="foo|bar"

NOTES =====

* This can be done by commit_pager_choice() or by a call right after
that in those places.
* regexp notation/version to be decided
* We should probably do this for long options only (and insert
"--<value>" rather than "<value>" to spare the "--" in config).
* We should probably do a prefix match.
* We could use GIT_OPTIONS_<CMD>_ALLOW and GIT_OPTIONS_<CMD>_DENY rather
than rely on negated regexps (if DENY matches deny, otherwise if ALLOW
matches allow, otherwise deny).
* We can get rid of a few config vars then...and may need to clean up
our option names.
Taking cover...
Michael
Previous: Jeff KingNext: David Pisoni
Message 10 of 14 in “Adds 'stash.index' configuration option”
  1. Adds 'stash.index' configuration optionDavid Pisoni, May 11, 2011
  2. Junio C HamanoMay 11, 2011
  3. Junio C HamanoMay 12, 2011
  4. David PisoniMay 12, 2011
  5. Junio C HamanoMay 12, 2011
  6. Michael J GruberMay 12, 2011
  7. Jeff KingMay 12, 2011
  8. Michael J GruberMay 12, 2011
  9. Jeff KingMay 12, 2011
  10. RFC proposal: set git defaults options from configMichael J Gruber, May 12, 2011
  11. David PisoniMay 12, 2011
  12. Jeff KingMay 16, 2011
  13. Jeff KingMay 16, 2011
  14. Michael J GruberMay 16, 2011

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.