threads / patch / 12587

patch, 11 partsAdd a function to set a non-default work tree

Subject: [PATCH 06/11] Add a function to set a non-default work tree

## tl;dr

One message between Mar 8, 2008 and Mar 8, 2008. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Daniel Barkalow· Mar 8, 2008, 23:04 UTC · lore
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
 cache.h       |    1 +
 environment.c |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)
Show changes to 2 files +7 −0

cache.h, environment.c

diff --git a/cache.h b/cache.h
index 6aae174..32e8746 100644
--- a/cache.h
+++ b/cache.h
@@ -311,6 +311,7 @@ extern char *get_index_file(void);
 extern char *get_graft_file(void);
 extern int set_git_dir(const char *path);
 extern const char *get_git_work_tree(void);
+extern void set_git_work_tree(const char *tree);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
 
diff --git a/environment.c b/environment.c
index 6739a3f..d6c6a6b 100644
--- a/environment.c
+++ b/environment.c
@@ -81,6 +81,12 @@ const char *get_git_dir(void)
 	return git_dir;
 }
 
+void set_git_work_tree(const char *new_work_tree)
+{
+	get_git_work_tree(); /* make sure it's initialized */
+	work_tree = xstrdup(make_absolute_path(new_work_tree));
+}
+
 const char *get_git_work_tree(void)
 {
 	static int initialized = 0;
-- 
1.5.4.3.327.g614d7.dirty

← back to recent threads