summaryrefslogtreecommitdiff
path: root/environment.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-08-01 00:29:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-08-01 07:38:31 (GMT)
commitd7ac12b25d375d32372b13f74e90425ca21d5dc1 (patch)
treea79db447d85ee9a56f51851f5eafba6daf197b8a /environment.c
parente663674722d8a64a208d8c176d5bfc340c04b964 (diff)
downloadgit-d7ac12b25d375d32372b13f74e90425ca21d5dc1.zip
git-d7ac12b25d375d32372b13f74e90425ca21d5dc1.tar.gz
git-d7ac12b25d375d32372b13f74e90425ca21d5dc1.tar.bz2
Add set_git_dir() function
With the function set_git_dir() you can reset the path that will be used for git_path(), git_dir() and friends. The responsibility to close files and throw away information from the old git_dir lies with the caller. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'environment.c')
-rw-r--r--environment.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/environment.c b/environment.c
index f83fb9e..a571fae 100644
--- a/environment.c
+++ b/environment.c
@@ -107,3 +107,11 @@ char *get_graft_file(void)
setup_git_env();
return git_graft_file;
}
+
+int set_git_dir(const char *path)
+{
+ if (setenv(GIT_DIR_ENVIRONMENT, path, 1))
+ return error("Could not set GIT_DIR to '%s'", path);
+ setup_git_env();
+ return 0;
+}