use xgetcwd() to set $GIT_DIR
Instead of dying of a segmentation fault if getcwd() returns NULL, use xgetcwd() to make sure to write a useful error message and then exit in an orderly fashion. Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
56b9f6e738
commit
4d3ab44d26
@ -537,10 +537,9 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
|
||||
usage(init_db_usage[0]);
|
||||
}
|
||||
if (is_bare_repository_cfg == 1) {
|
||||
static char git_dir[PATH_MAX+1];
|
||||
|
||||
setenv(GIT_DIR_ENVIRONMENT,
|
||||
getcwd(git_dir, sizeof(git_dir)), argc > 0);
|
||||
char *cwd = xgetcwd();
|
||||
setenv(GIT_DIR_ENVIRONMENT, cwd, argc > 0);
|
||||
free(cwd);
|
||||
}
|
||||
|
||||
if (init_shared_repository != -1)
|
||||
|
||||
Reference in New Issue
Block a user