[PATCH] Allow built-ins to also use -c var=val via alias

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

 



The previous commit 2b64fc8 (pass "git -c foo=bar" params through
environment, 2010-08-23) tried to make all the one-shot configuration
setting made via the "-c" option to the "git" wrapper go through an
environment variable, so that the value can be propagated to external
commands _as well as_ the internal ones, but ended up breaking one of the
codepaths that invokes internal commands, because it incorrectly assumed
that git_config_from_parmeters() can never be called in a single process
after git_config_parse_environment() was called once.

Not so.

When the options came as part of an alias to an internal command, e.g.

  [alias]
    aw = -c apply.whitespace=fix apply

and then run as "git aw P.diff", we have already read the configuration to
find out about the alias definition (setting loaded_environment to true),
then pushed apply.whitespace=fix to the environment, but not to the
in-core list of configuration variables. The implementation of the
internal command, e.g. cmd_apply(), will try to read from git_config() but
the setting is lost, as the environment is never read in this codepath.

Add the in-core queuing of the parameters back to fix this.

Note that the handling of such an alias is still broken for another reason
in this codepath; a separate patch fixes it.

While at it, avoid getting our test confused by GIT_CONFIG_PARAMETERS
exported to the tester's environment.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---

 * And this is the other fix. Applying this on top of 2b64fc8 does not
   make "git aw P.diff" in the test t1300 in the other patch, but this
   is prerequisite for the other fix to work in a more modern codebase.

 config.c      |    1 +
 t/test-lib.sh |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/config.c b/config.c
index c2c995f..c803ae8 100644
--- a/config.c
+++ b/config.c
@@ -43,6 +43,7 @@ void git_config_push_parameter(const char *text)
 		strbuf_addstr(&env, old);
 		strbuf_addch(&env, ' ');
 	}
+	git_config_parse_parameter(text);
 	sq_quote_buf(&env, text);
 	setenv(CONFIG_DATA_ENVIRONMENT, env.buf, 1);
 	strbuf_release(&env);
diff --git a/t/test-lib.sh b/t/test-lib.sh
index e5523dd..0b1358e 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -57,6 +57,7 @@ GIT_AUTHOR_NAME='A U Thor'
 unset GIT_COMMITTER_DATE
 GIT_COMMITTER_EMAIL=committer@xxxxxxxxxxx
 GIT_COMMITTER_NAME='C O Mitter'
+unset GIT_CONFIG_PARAMETERS
 unset GIT_DIFF_OPTS
 unset GIT_DIR
 unset GIT_WORK_TREE
-- 
1.7.5.2.459.g67e41

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]