diff options
-rw-r--r-- | dir.c | 25 | ||||
-rw-r--r-- | dir.h | 1 | ||||
-rw-r--r-- | submodule.c | 25 | ||||
-rw-r--r-- | submodule.h | 1 |
4 files changed, 26 insertions, 26 deletions
@@ -2748,3 +2748,28 @@ void untracked_cache_add_to_index(struct index_state *istate, { untracked_cache_invalidate_path(istate, path); } + +/* Update gitfile and core.worktree setting to connect work tree and git dir */ +void connect_work_tree_and_git_dir(const char *work_tree_, const char *git_dir_) +{ + struct strbuf file_name = STRBUF_INIT; + struct strbuf rel_path = STRBUF_INIT; + char *git_dir = xstrdup(real_path(git_dir_)); + char *work_tree = xstrdup(real_path(work_tree_)); + + /* Update gitfile */ + strbuf_addf(&file_name, "%s/.git", work_tree); + write_file(file_name.buf, "gitdir: %s", + relative_path(git_dir, work_tree, &rel_path)); + + /* Update core.worktree setting */ + strbuf_reset(&file_name); + strbuf_addf(&file_name, "%s/config", git_dir); + git_config_set_in_file(file_name.buf, "core.worktree", + relative_path(work_tree, git_dir, &rel_path)); + + strbuf_release(&file_name); + strbuf_release(&rel_path); + free(work_tree); + free(git_dir); +} @@ -335,4 +335,5 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked); void add_untracked_cache(struct index_state *istate); void remove_untracked_cache(struct index_state *istate); +extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir); #endif diff --git a/submodule.c b/submodule.c index d4f7afe2f1..0bb50b4b62 100644 --- a/submodule.c +++ b/submodule.c @@ -1222,31 +1222,6 @@ int merge_submodule(unsigned char result[20], const char *path, return 0; } -/* Update gitfile and core.worktree setting to connect work tree and git dir */ -void connect_work_tree_and_git_dir(const char *work_tree_, const char *git_dir_) -{ - struct strbuf file_name = STRBUF_INIT; - struct strbuf rel_path = STRBUF_INIT; - char *git_dir = xstrdup(real_path(git_dir_)); - char *work_tree = xstrdup(real_path(work_tree_)); - - /* Update gitfile */ - strbuf_addf(&file_name, "%s/.git", work_tree); - write_file(file_name.buf, "gitdir: %s", - relative_path(git_dir, work_tree, &rel_path)); - - /* Update core.worktree setting */ - strbuf_reset(&file_name); - strbuf_addf(&file_name, "%s/config", git_dir); - git_config_set_in_file(file_name.buf, "core.worktree", - relative_path(work_tree, git_dir, &rel_path)); - - strbuf_release(&file_name); - strbuf_release(&rel_path); - free(work_tree); - free(git_dir); -} - int parallel_submodules(void) { return parallel_jobs; diff --git a/submodule.h b/submodule.h index d9e197a948..4e3bf469b4 100644 --- a/submodule.h +++ b/submodule.h @@ -65,7 +65,6 @@ int merge_submodule(unsigned char result[20], const char *path, const unsigned c int find_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name, struct string_list *needs_pushing); int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name); -void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir); int parallel_submodules(void); /* |