Skip to content

Commit 9277d60

Browse files
committed
git --bare cmd: do not unconditionally nuke GIT_DIR
"GIT_DIR=some.where git --bare cmd" and worse yet "git --git-dir=some.where --bare cmd" were very confusing. They both ignored git-dir specified, and instead made $cwd as GIT_DIR. This changes --bare not to override existing GIT_DIR. This has been like this for a long time. Let's hope nobody sane relied on this insane behaviour. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6adcca3 commit 9277d60

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Documentation/git.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ OPTIONS
120120
variable.
121121

122122
--bare::
123-
Same as --git-dir=`pwd`.
123+
Treat the repository as a bare repository. If GIT_DIR
124+
environment is not set, it is set to the current working
125+
directory.
126+
124127

125128
FURTHER DOCUMENTATION
126129
---------------------

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
9494
} else if (!strcmp(cmd, "--bare")) {
9595
static char git_dir[PATH_MAX+1];
9696
is_bare_repository_cfg = 1;
97-
setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 1);
97+
setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 0);
9898
if (envchanged)
9999
*envchanged = 1;
100100
} else {

0 commit comments

Comments
 (0)