[PATCH 5/9] Add set_git_dir() function

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <gitster@...>, <git@...>, <matled@...>
Date: Sunday, July 29, 2007 - 7:25 pm

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>
---
 cache.h       |    1 +
 environment.c |    8 ++++++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/cache.h b/cache.h
index c0cab34..36963f2 100644
--- a/cache.h
+++ b/cache.h
@@ -216,6 +216,7 @@ extern char *get_refs_directory(void);
 extern char *get_index_file(void);
 extern char *get_graft_file(void);
 extern const char *get_git_work_tree(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 26f41af..2af12fd 100644
--- a/environment.c
+++ b/environment.c
@@ -124,3 +124,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;
+}
-- 
1.5.3.rc3.28.g1406


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/9] work-tree clean ups, Johannes Schindelin, (Sun Jul 29, 7:23 pm)
Re: [PATCH 0/9] work-tree clean ups, Johannes Schindelin, (Tue Jul 31, 8:28 pm)
Re: [PATCH 0/9] work-tree clean ups, Junio C Hamano, (Tue Jul 31, 8:55 pm)
Re: [PATCH 0/9] work-tree clean ups, Johannes Schindelin, (Tue Jul 31, 9:13 pm)
Re: [PATCH 0/9] work-tree clean ups, Johannes Schindelin, (Wed Aug 1, 6:56 am)
[PATCH 4/4] Clean up work-tree handling, Johannes Schindelin, (Tue Jul 31, 8:30 pm)
Re: [PATCH 4/4] Clean up work-tree handling, Junio C Hamano, (Wed Aug 1, 4:59 am)
Re: [PATCH 4/4] Clean up work-tree handling, Johannes Schindelin, (Wed Aug 1, 7:53 am)
Re: [PATCH 4/4] Clean up work-tree handling, Junio C Hamano, (Wed Aug 1, 1:17 am)
Re: [PATCH 4/4] Clean up work-tree handling, Johannes Schindelin, (Wed Aug 1, 7:46 am)
Re: [PATCH 4/4] Clean up work-tree handling, Junio C Hamano, (Thu Aug 2, 3:04 am)
[PATCH 3/4] Add set_git_dir() function, Johannes Schindelin, (Tue Jul 31, 8:29 pm)
[PATCH 2/4] Add functions get_relative_cwd() and is_inside_d..., Johannes Schindelin, (Tue Jul 31, 8:29 pm)
[NOT-SERIOUS PATCH] Make get_relative_cwd() not accept NULL ..., Johannes Schindelin, (Wed Aug 1, 11:26 am)
[PATCH] get_relative_cwd(): clarify why it handles dir == NULL, Johannes Schindelin, (Wed Aug 1, 2:26 pm)
Re: [PATCH 2/4] Add functions get_relative_cwd() and is_insi..., Johannes Schindelin, (Wed Aug 1, 7:38 am)
[PATCH 1/4] Add is_absolute_path() and make_absolute_path(), Johannes Schindelin, (Tue Jul 31, 8:28 pm)
[UNWANTED PATCH] Die if core.bare = true and core.worktree i..., Johannes Schindelin, (Sun Jul 29, 7:29 pm)
[PATCH 9/9] Fix t1500 for sane work-tree behavior, Johannes Schindelin, (Sun Jul 29, 7:26 pm)
[PATCH 8/9] Fix t1501 for updated work-tree logic, Johannes Schindelin, (Sun Jul 29, 7:26 pm)
[PATCH 7/9] init: use get_git_work_tree() instead of rolling..., Johannes Schindelin, (Sun Jul 29, 7:25 pm)
[PATCH 6/9] work-trees are allowed inside a git-dir, Johannes Schindelin, (Sun Jul 29, 7:25 pm)
[PATCH 5/9] Add set_git_dir() function, Johannes Schindelin, (Sun Jul 29, 7:25 pm)
[PATCH 4/9] Clean up work-tree handling, Johannes Schindelin, (Sun Jul 29, 7:25 pm)
[PATCH 3/9] white space fixes in setup.c, Johannes Schindelin, (Sun Jul 29, 7:24 pm)
[PATCH 2/9] Add functions get_relative_cwd() and is_inside_d..., Johannes Schindelin, (Sun Jul 29, 7:24 pm)
[PATCH 1/9] Add is_absolute_path() and make_absolute_path(), Johannes Schindelin, (Sun Jul 29, 7:24 pm)