working directory with GIT_DIR
Today on IRC someone asked if it is possible to use GIT_DIR with a working directory. At the moment cwd is used as working directory (no subdirectory support). I've been thinking for a while about adding an environment variable to specify the working directory in addition to GIT_DIR to allow the .git directory to be somewhere else than the working directory.
I've hacked up a patch to do this using either an environment variable or take the directory from $GIT_DIR/topdir/ (supposed to be a symlink).
Any comments? Is there any interest to add this feature to git?
Here is the patch if anyone is interested, definetly needs some cleanup. I'm just asking before I put any further effort into this.
---
allow to specify a working directory with GIT_DIR
set the environment variable GIT_TOP_DIR to the working directory or $GIT_DIR/topdir/ is tried (e.g. a symlink)
--- cache.h | 1 + environment.c | 4 ++++ setup.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 53 insertions(+), 6 deletions(-)
cache.h +1 -0
@@ -118,6 +118,7 @@ extern struct cache_tree *active_cache_tree;extern int cache_errno;#define GIT_DIR_ENVIRONMENT "GIT_DIR" +#define GIT_WORKING_DIR_ENVIRONMENT "GIT_TOP_DIR"#define DEFAULT_GIT_DIR_ENVIRONMENT ".git"#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
environment.c +4 -0
@@ -59,7 +59,11 @@ int is_bare_repository(void)const char *dir, *s;if (0 <= is_bare_repository_cfg)return is_bare_repository_cfg; +/* FIXME */ +return 0 ; +if (getenv (GIT_WORKING_DIR_ENVIRONMENT )) +return 0 ; dir =get_git_dir ();if (!strcmp (dir,DEFAULT_GIT_DIR_ENVIRONMENT ))return 0 ;
setup.c +48 -6
63 lines not on this page · raw message
Signature · 1 line
1.5.0.rc3.1.gbc850-dirty