mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
git clone was failing with 'invalid object name HEAD' if ran from cmd.exe directly
environment.c caches results of many getenv calls. Under MinGW setenv(X) invalidates all previous values returned by getenv(X) so cached values become dangling pointers. Replaced all setenv(GIT_DIR, ...) with set_git_dir Signed-off-by: Dmitry Kakurin <Dmitry.Kakurin@gmail.com>
This commit is contained in:
6
git.c
6
git.c
@@ -67,14 +67,14 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
|
||||
fprintf(stderr, "No directory given for --git-dir.\n" );
|
||||
usage(git_usage_string);
|
||||
}
|
||||
setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1);
|
||||
set_git_dir( (*argv)[1] );
|
||||
if (envchanged)
|
||||
*envchanged = 1;
|
||||
(*argv)++;
|
||||
(*argc)--;
|
||||
handled++;
|
||||
} else if (!prefixcmp(cmd, "--git-dir=")) {
|
||||
setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);
|
||||
set_git_dir(cmd + 10);
|
||||
if (envchanged)
|
||||
*envchanged = 1;
|
||||
} else if (!strcmp(cmd, "--work-tree")) {
|
||||
@@ -93,7 +93,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
|
||||
*envchanged = 1;
|
||||
} else if (!strcmp(cmd, "--bare")) {
|
||||
static char git_dir[PATH_MAX+1];
|
||||
setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 1);
|
||||
set_git_dir(getcwd(git_dir, sizeof(git_dir)));
|
||||
if (envchanged)
|
||||
*envchanged = 1;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user