[PATCH v8 0/8] config: allow specifying config entries via envvar pairs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

this is the eighth 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.

Changes were all proposed by Junio and are solely in patch 2/8:

    - Improved the error message to include the the config key when the
      environment variable name is missing.

    - Dropped needless use of env(1) in added tests.

    - The NONEXISTENT envvar is being unset now to fix the case where
      tests may be run with that variable being set by the user.

Please see the attached range-diff for more details.

Patrick


Jeff King (2):
  quote: make sq_dequote_step() a public function
  config: parse more robust format in GIT_CONFIG_PARAMETERS

Patrick Steinhardt (6):
  git: add `--super-prefix` to usage string
  config: add new way to pass config via `--config-env`
  config: extract function to parse config pairs
  config: store "git -c" variables using more robust format
  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                     | 209 ++++++++++++++++++++++++++++----
 config.h                     |   1 +
 environment.c                |   8 +-
 environment.h                |  12 ++
 git.c                        |   3 +
 quote.c                      |  15 ++-
 quote.h                      |  18 ++-
 t/t1300-config.sh            | 223 ++++++++++++++++++++++++++++++++++-
 11 files changed, 491 insertions(+), 39 deletions(-)
 create mode 100644 environment.h

Range-diff against v7:
1:  55fa4d0d11 = 1:  55fa4d0d11 git: add `--super-prefix` to usage string
2:  b9cf47afe8 ! 2:  470396d36f config: add new way to pass config via `--config-env`
    @@ config.c: void git_config_push_parameter(const char *text)
     +		die(_("invalid config format: %s"), spec);
     +	env_name++;
     +	if (!*env_name)
    -+		die(_("missing value for --config-env"));
    ++		die(_("missing environment variable name for configuration '%.*s'"),
    ++		    (int)(env_name - spec - 1), spec);
     +
     +	env_value = getenv(env_name);
     +	if (!env_value)
    @@ t/t1300-config.sh: test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' '
     +	false
     +	EOF
     +	{
    -+		env ENVVAR=value git --config-env=core.name=ENVVAR config core.name &&
    -+		env ENVVAR=value git --config-env=foo.CamelCase=ENVVAR config foo.camelcase &&
    -+		env ENVVAR= git --config-env=foo.flag=ENVVAR config --bool foo.flag
    ++		ENVVAR=value git --config-env=core.name=ENVVAR config core.name &&
    ++		ENVVAR=value git --config-env=foo.CamelCase=ENVVAR config foo.camelcase &&
    ++		ENVVAR= git --config-env=foo.flag=ENVVAR config --bool foo.flag
     +	} >actual &&
     +	test_cmp expect actual
     +'
     +
     +test_expect_success 'git --config-env fails with invalid parameters' '
     +	test_must_fail git --config-env=foo.flag config --bool foo.flag 2>error &&
    -+	test_i18ngrep "invalid config format" error &&
    ++	test_i18ngrep "invalid config format: foo.flag" error &&
     +	test_must_fail git --config-env=foo.flag= config --bool foo.flag 2>error &&
    -+	test_i18ngrep "missing value for --config-env" error &&
    ++	test_i18ngrep "missing environment variable name for configuration ${SQ}foo.flag${SQ}" error &&
    ++	sane_unset NONEXISTENT &&
     +	test_must_fail git --config-env=foo.flag=NONEXISTENT config --bool foo.flag 2>error &&
     +	test_i18ngrep "missing environment variable ${SQ}NONEXISTENT${SQ} for configuration ${SQ}foo.flag${SQ}" error
     +'
    @@ t/t1300-config.sh: test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' '
     +	bar.cmd cmd-value
     +	bar.env env-value
     +	EOF
    -+	env ENVVAR=env-value git \
    ++	ENVVAR=env-value git \
     +		-c bar.cmd=cmd-value \
     +		--config-env=bar.env=ENVVAR \
     +		config --get-regexp "^bar.*" >actual &&
    @@ t/t1300-config.sh: test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' '
     +	cmd
     +	EOF
     +	{
    -+		env ENVVAR=env git -c bar.bar=cmd --config-env=bar.bar=ENVVAR config bar.bar &&
    -+		env ENVVAR=env git --config-env=bar.bar=ENVVAR -c bar.bar=cmd config bar.bar
    ++		ENVVAR=env git -c bar.bar=cmd --config-env=bar.bar=ENVVAR config bar.bar &&
    ++		ENVVAR=env git --config-env=bar.bar=ENVVAR -c bar.bar=cmd config bar.bar
     +	} >actual &&
     +	test_cmp expect actual
     +'
3:  1b47f0db98 = 3:  7a7a4ae234 quote: make sq_dequote_step() a public function
4:  b9565a050e = 4:  39552eb8b9 config: extract function to parse config pairs
5:  8f998ac81a ! 5:  36c2a51b13 config: store "git -c" variables using more robust format
    @@ config.c: void git_config_push_parameter(const char *text)
     +	key = xmemdupz(spec, env_name - spec);
      	env_name++;
      	if (!*env_name)
    - 		die(_("missing value for --config-env"));
    + 		die(_("missing environment variable name for configuration '%.*s'"),
     @@ config.c: void git_config_push_env(const char *spec)
      		die(_("missing environment variable '%s' for configuration '%.*s'"),
      		    env_name, (int)(env_name - spec - 1), spec);
6:  e7b073c9dc = 6:  d67a3c0f9f config: parse more robust format in GIT_CONFIG_PARAMETERS
7:  6c1800a18f = 7:  28cc229ade environment: make `getenv_safe()` a public function
8:  ac9e778704 = 8:  07697b0c21 config: allow specifying config entries via envvar pairs
-- 
2.30.0

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux