diff options
-rw-r--r-- | cache.h | 1 | ||||
-rw-r--r-- | environment.c | 8 |
2 files changed, 9 insertions, 0 deletions
@@ -214,6 +214,7 @@ extern char *get_object_directory(void); extern char *get_refs_directory(void); extern char *get_index_file(void); extern char *get_graft_file(void); +extern int set_git_dir(const char *path); #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" 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; +} |