[PATCH v7 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 seventh 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 error handling for the
`--config-env` switch:

    - Error messages are now correctly marked for translation.

    - A separate error message is given if no value is passed to
      `--config-env`. Previously, we would've tried to look up the
      empty environment variable (`getenv("")`).

    - The error message when the environment variable is missing was
      improved.

Please see the attached ranged-diff for further 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                     | 208 ++++++++++++++++++++++++++++----
 config.h                     |   1 +
 environment.c                |   8 +-
 environment.h                |  12 ++
 git.c                        |   3 +
 quote.c                      |  15 ++-
 quote.h                      |  18 ++-
 t/t1300-config.sh            | 222 ++++++++++++++++++++++++++++++++++-
 11 files changed, 489 insertions(+), 39 deletions(-)
 create mode 100644 environment.h

Range-diff against v6:
1:  cd3de0743a = 1:  55fa4d0d11 git: add `--super-prefix` to usage string
2:  9b8461010e ! 2:  b9cf47afe8 config: add new way to pass config via `--config-env`
    @@ config.c: void git_config_push_parameter(const char *text)
     +
     +	env_name = strrchr(spec, '=');
     +	if (!env_name)
    -+		die("invalid config format: %s", spec);
    ++		die(_("invalid config format: %s"), spec);
     +	env_name++;
    ++	if (!*env_name)
    ++		die(_("missing value for --config-env"));
     +
     +	env_value = getenv(env_name);
     +	if (!env_value)
    -+		die("config variable missing for '%s'", env_name);
    ++		die(_("missing environment variable '%s' for configuration '%.*s'"),
    ++		    env_name, (int)(env_name - spec - 1), spec);
     +
     +	strbuf_add(&buf, spec, env_name - spec);
     +	strbuf_addstr(&buf, env_value);
    @@ t/t1300-config.sh: test_expect_success 'detect bogus GIT_CONFIG_PARAMETERS' '
     +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_must_fail git --config-env=foo.flag= config --bool foo.flag 2>error &&
    ++	test_i18ngrep "missing value for --config-env" error &&
     +	test_must_fail git --config-env=foo.flag=NONEXISTENT config --bool foo.flag 2>error &&
    -+	test_i18ngrep "config variable missing" error
    ++	test_i18ngrep "missing environment variable ${SQ}NONEXISTENT${SQ} for configuration ${SQ}foo.flag${SQ}" error
     +'
     +
     +test_expect_success 'git -c and --config-env work together' '
3:  9d4c8d7be9 = 3:  1b47f0db98 quote: make sq_dequote_step() a public function
4:  0a9b085fe5 = 4:  b9565a050e config: extract function to parse config pairs
5:  b96686c9cd ! 5:  8f998ac81a config: store "git -c" variables using more robust format
    @@
      ## Metadata ##
    -Author: Jeff King <peff@xxxxxxxx>
    +Author: Patrick Steinhardt <ps@xxxxxx>
     
      ## Commit message ##
         config: store "git -c" variables using more robust format
    @@ config.c: void git_config_push_parameter(const char *text)
      
      	env_name = strrchr(spec, '=');
      	if (!env_name)
    - 		die("invalid config format: %s", spec);
    + 		die(_("invalid config format: %s"), spec);
     +	key = xmemdupz(spec, env_name - spec);
      	env_name++;
    - 
    - 	env_value = getenv(env_name);
    - 	if (!env_value)
    - 		die("config variable missing for '%s'", env_name);
    + 	if (!*env_name)
    + 		die(_("missing value for --config-env"));
    +@@ 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);
      
     -	strbuf_add(&buf, spec, env_name - spec);
     -	strbuf_addstr(&buf, env_value);
6:  6597700ffb = 6:  e7b073c9dc config: parse more robust format in GIT_CONFIG_PARAMETERS
7:  cade8fb12f = 7:  6c1800a18f environment: make `getenv_safe()` a public function
8:  4e3f208d13 = 8:  ac9e778704 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