mbox series

[v6,0/8] config: allow specifying config entries via env

Message ID cover.1610001187.git.ps@pks.im (mailing list archive)
Headers show
Series config: allow specifying config entries via env | expand

Message

Patrick Steinhardt Jan. 7, 2021, 6:36 a.m. UTC
Hi,

this is the sixth version of my patch series which aims to implement a
way to pass config entries via the environment while avoiding any
requirements to perform shell quoting on the user's side.

The only change in this version is improved formatting and wording of
the documentation as proposed by Junio. Please see the attached
range-diff.

Patrick

Jeff King (3):
  quote: make sq_dequote_step() a public function
  config: store "git -c" variables using more robust format
  config: parse more robust format in GIT_CONFIG_PARAMETERS

Patrick Steinhardt (5):
  git: add `--super-prefix` to usage string
  config: add new way to pass config via `--config-env`
  config: extract function to parse config pairs
  environment: make `getenv_safe()` a public function
  config: allow specifying config entries via envvar pairs

 Documentation/git-config.txt |  16 +++
 Documentation/git.txt        |  24 +++-
 cache.h                      |   1 +
 config.c                     | 205 ++++++++++++++++++++++++++++----
 config.h                     |   1 +
 environment.c                |   8 +-
 environment.h                |  12 ++
 git.c                        |   3 +
 quote.c                      |  15 ++-
 quote.h                      |  18 ++-
 t/t1300-config.sh            | 220 ++++++++++++++++++++++++++++++++++-
 11 files changed, 484 insertions(+), 39 deletions(-)
 create mode 100644 environment.h

Range-diff against v5:
1:  470521e728 = 1:  cd3de0743a git: add `--super-prefix` to usage string
2:  56c9221c4c ! 2:  9b8461010e config: add new way to pass config via `--config-env`
    @@ Documentation/git.txt: config file). Including the equals but with an empty valu
      --type=bool` will convert to `false`.
      
     +--config-env=<name>=<envvar>::
    -+	Like `-c <name>=<var>` except the value is the name of an
    ++	Like `-c <name>=<value>`, give configuration variable
    ++	'<name>' a value, where <envvar> is the name of an
     +	environment variable from which to retrieve the value. Unlike
     +	`-c` there is no shortcut for directly setting the value to an
     +	empty string, instead the environment variable itself must be
    -+	set to the empty strin. Errors if the `<envvar>` does not exist
    ++	set to the empty string.  It is an error if the `<envvar>` does not exist
     +	in the environment. `<envvar>` may not contain an equals sign
     +	to avoid ambiguity with `<name>`s which contain one.
    -+
    -+	This is useful for cases where you want to pass transitory
    -+	configuration options to git, but are doing so on OS's where
    -+	other processes might be able to read your cmdline
    -+	(e.g. `/proc/self/cmdline`), but not your environ
    -+	(e.g. `/proc/self/environ`). That behavior is the default on
    -+	Linux, but may not be on your system.
    -+
    -+	Note that this might add security for variables such as
    -+	`http.extraHeader` where the sensitive information is part of
    -+	the value, but not e.g. `url.<base.insteadOf` where the
    -+	sensitive information can be part of the key.
    +++
    ++This is useful for cases where you want to pass transitory
    ++configuration options to git, but are doing so on OS's where
    ++other processes might be able to read your cmdline
    ++(e.g. `/proc/self/cmdline`), but not your environ
    ++(e.g. `/proc/self/environ`). That behavior is the default on
    ++Linux, but may not be on your system.
    +++
    ++Note that this might add security for variables such as
    ++`http.extraHeader` where the sensitive information is part of
    ++the value, but not e.g. `url.<base>.insteadOf` where the
    ++sensitive information can be part of the key.
     +
      --exec-path[=<path>]::
      	Path to wherever your core Git programs are installed.
3:  5729f5d406 = 3:  9d4c8d7be9 quote: make sq_dequote_step() a public function
4:  8c6cdd57a0 = 4:  0a9b085fe5 config: extract function to parse config pairs
5:  ff96e59e79 = 5:  b96686c9cd config: store "git -c" variables using more robust format
6:  d832f3dedf = 6:  6597700ffb config: parse more robust format in GIT_CONFIG_PARAMETERS
7:  2f51a0c5fc = 7:  cade8fb12f environment: make `getenv_safe()` a public function
8:  dfceffd8d4 ! 8:  4e3f208d13 config: allow specifying config entries via envvar pairs
    @@ Documentation/git-config.txt: GIT_CONFIG_NOSYSTEM::
     +	pairs are processed. These environment variables will override values
     +	in configuration files, but will be overridden by any explicit options
     +	passed via `git -c`.
    -+
    -+	This is useful for cases where you want to spawn multiple git commands
    -+	with a common configuration but cannot depend on a configuration file,
    -+	for example when writing scripts.
    +++
    ++This is useful for cases where you want to spawn multiple git commands
    ++with a common configuration but cannot depend on a configuration file,
    ++for example when writing scripts.
     +
      
      [[EXAMPLES]]