[PATCH] Fix premature call to git_config() causing t1020-subdirectory to fail

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

 



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@xxxxxxxxxxx>
---

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

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

  Powered by Linux