From d7ac12b25d375d32372b13f74e90425ca21d5dc1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 1 Aug 2007 01:29:38 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- environment.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'environment.c') diff --git a/environment.c b/environment.c index f83fb9e448..a571fae607 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; +} -- cgit v1.2.1