Re: [PATCH/RFH] Fix initialization of a bare repository

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

 



Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes:

> how about this on top (or squashed):

Looks good.  On top of these two...

An earlier commit 6acbcb92 unfortunately defined --bare as a
synonym to "export GIT_DIR=`pwd`", but I have to say that this
was done without much thinking.  To be more precise and fair to
the commit, it did so without thinking outside the case it
wanted to deal with.

It wanted to deal with the case where the user did _not_ have
GIT_DIR exported, and did:

	$ cd some-bare-repository
        $ git --bare repack -a -d

In this case, its exporting cwd as GIT_DIR _is_ justified.
However, what it did not think about is what should be the right
behaviour when the user already had GIT_DIR pointing elsewhere,
iow:

	$ GIT_DIR=/some/where/foo.git git --bare command

or (worse yet)

	$ git --git-dir=/some/where/foo.git --bare command

I think it should just keep using the existing value from the
enviroment, instead of overriding.

*W*A*R*N*I*N*G*

This _CHANGES_ semantics, so it has a great risk of breaking
people's scripts.  However, I have a suspicion that nobody
relied on the insane behaviour.

-- >8 --
[PATCH] 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 <gitster@xxxxxxxxx>
---
 Documentation/git.txt |    5 ++++-
 git.c                 |    2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index 3b0d530..75b3e1b 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -120,7 +120,10 @@ OPTIONS
 	variable.
 
 --bare::
-	Same as --git-dir=`pwd`.
+	Treat the repository as a bare repository.  If GIT_DIR
+	environment is not set, it is set to the current working
+	directory.
+
 
 FURTHER DOCUMENTATION
 ---------------------
diff --git a/git.c b/git.c
index b6e292e..fd3d83c 100644
--- a/git.c
+++ b/git.c
@@ -94,7 +94,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
 		} else if (!strcmp(cmd, "--bare")) {
 			static char git_dir[PATH_MAX+1];
 			is_bare_repository_cfg = 1;
-			setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 1);
+			setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 0);
 			if (envchanged)
 				*envchanged = 1;
 		} else {
-- 
1.5.3.rc6.48.g17437

-
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