Skip to content

Commit 717c397

Browse files
René Scharfegitster
authored andcommitted
setenv(GIT_DIR) clean-up
This patch converts the setenv() calls in path.c and setup.c. After the call, git grep with a pager works again in bare repos. It leaves the setenv(GIT_DIR_ENVIRONMENT, ...) calls in git.c alone, as they respond to command line switches that emulate the effect of setting the environment variable directly. The remaining site in environment.c is in set_git_dir() and is left alone, too, of course. Finally, builtin-init-db.c is left changed because the repo is still being carefully constructed when the environment variable is set. This fixes git shortlog when run inside a git directory, which had been broken by abe549e. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab35469 commit 717c397

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ char *enter_repo(char *path, int strict)
336336

337337
if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
338338
validate_headref("HEAD") == 0) {
339-
setenv(GIT_DIR_ENVIRONMENT, ".", 1);
339+
set_git_dir(".");
340340
check_repository_format();
341341
return path;
342342
}

setup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ const char *setup_git_directory_gently(int *nongit_ok)
404404
inside_work_tree = 0;
405405
if (offset != len) {
406406
cwd[offset] = '\0';
407-
setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
407+
set_git_dir(cwd);
408408
} else
409-
setenv(GIT_DIR_ENVIRONMENT, ".", 1);
409+
set_git_dir(".");
410410
check_repository_format_gently(nongit_ok);
411411
return NULL;
412412
}

0 commit comments

Comments
 (0)