Skip to content

Commit

Permalink
Add set_git_dir() function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Aug 1, 2007
1 parent e663674 commit d7ac12b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 8 additions & 0 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit d7ac12b

Please sign in to comment.