[PATCH] Fix premature call to git_config() causing t1020-subdirectory to fail
- From
Johan Herland <johan@herland.net>
- Date
- Feb 26, 2008, 15:40 UTC
- Message-ID
- <200802261640.48770.johan@herland.net>
- In-Reply-To
- <200802260321.14038.johan@herland.net>
We need to call git_config(git_default_config) in order to get user.name and user.email (so that reflogs will be correct), but if we do it too early, it interferes with the setup of reference repos. Therefore, move git_config() call to _after_ the reference has been setup (but before we start writing reflogs). However, in order for git_config() to read in the global configuration at that point, we must unset CONFIG_ENVIRONMENT.
There are probably better ways of resolving this issue.
Signed-off-by: Johan Herland <johan@herland.net> ---
On Tuesday 26 February 2008, Johan Herland wrote:
> - Call git_config(git_default_config) in order to properly set up > user.name and user.email for reflogs (This BREAKS test #9 in > t1020-subdirectory.sh. Have yet to figure out why)
Here is a fix for this breakage, although I think it's ugly as hell.
But with this fix, and the other one I just sent out for the for_each_ref() corruption, the whole test suite finally passes on my box.
Feel free to incorporate this into the further builtin-clone work, or ignore it, and find better ways of solving these issues.
Have fun! :)
...Johan
builtin-clone.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c index d5baffc..c02a04c 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -346,8 +346,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix) char branch_top[256], key[256], refname[256], value[256]; struct strbuf reflog_msg; - git_config(git_default_config); - clone_pid = getpid(); argc = parse_options(argc, argv, builtin_clone_options, @@ -423,6 +421,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix) set_git_dir(make_absolute_path(git_dir)); + /* This must happen _after_ git_dir has been set up */ + unsetenv(CONFIG_ENVIRONMENT); /* need user/email from global config */ + git_config(git_default_config); + if (option_bare) git_config_set("core.bare", "true");
-- 1.5.4.3.342.g99e8