From: Stefan Beller <sbeller@google.com>
To: bmwill@google.com
Cc: git@vger.kernel.org, pclouds@gmail.com, gitster@pobox.com,
Stefan Beller <sbeller@google.com>
Subject: [PATCHv6 6/7] move connect_work_tree_and_git_dir to dir.h
Date: Wed, 7 Dec 2016 17:46:22 -0800 [thread overview]
Message-ID: <20161208014623.7588-7-sbeller@google.com> (raw)
In-Reply-To: <20161208014623.7588-1-sbeller@google.com>
That function was primarily used by submodule code, but the function
itself is not inherently about submodules. In the next patch we'll
introduce relocate_git_dir, which can be used by worktrees as well,
so find a neutral middle ground in dir.h.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
dir.c | 26 ++++++++++++++++++++++++++
dir.h | 1 +
submodule.c | 26 --------------------------
submodule.h | 1 -
4 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/dir.c b/dir.c
index bfa8c8a9a5..8b74997c66 100644
--- a/dir.c
+++ b/dir.c
@@ -2748,3 +2748,29 @@ 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 *real_git_dir = xstrdup(real_path(git_dir));
+ char *real_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(real_git_dir, real_work_tree, &rel_path));
+
+ /* Update core.worktree setting */
+ strbuf_reset(&file_name);
+ strbuf_addf(&file_name, "%s/config", real_git_dir);
+ git_config_set_in_file(file_name.buf, "core.worktree",
+ relative_path(real_work_tree, real_git_dir,
+ &rel_path));
+
+ strbuf_release(&file_name);
+ strbuf_release(&rel_path);
+ free(real_work_tree);
+ free(real_git_dir);
+}
diff --git a/dir.h b/dir.h
index 97c83bb383..051674a431 100644
--- a/dir.h
+++ b/dir.h
@@ -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 66c5ce5a24..0bb50b4b62 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1222,32 +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 *real_git_dir = xstrdup(real_path(git_dir));
- char *real_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(real_git_dir, real_work_tree, &rel_path));
-
- /* Update core.worktree setting */
- strbuf_reset(&file_name);
- strbuf_addf(&file_name, "%s/config", real_git_dir);
- git_config_set_in_file(file_name.buf, "core.worktree",
- relative_path(real_work_tree, real_git_dir,
- &rel_path));
-
- strbuf_release(&file_name);
- strbuf_release(&rel_path);
- free(real_work_tree);
- free(real_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);
/*
--
2.11.0.rc2.30.gc512cbd.dirty
next prev parent reply other threads:[~2016-12-08 1:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-08 1:46 [PATCHv6 0/7] submodule embedgitdirs Stefan Beller
2016-12-08 1:46 ` [PATCHv6 1/7] submodule: use absolute path for computing relative path connecting Stefan Beller
2016-12-08 9:45 ` Duy Nguyen
2016-12-08 1:46 ` [PATCHv6 2/7] submodule helper: support super prefix Stefan Beller
2016-12-08 9:52 ` Duy Nguyen
2016-12-08 20:19 ` Stefan Beller
2016-12-08 1:46 ` [PATCHv6 3/7] test-lib-functions.sh: teach test_commit -C <dir> Stefan Beller
2016-12-08 1:46 ` [PATCHv6 4/7] worktree: get worktrees from submodules Stefan Beller
2016-12-08 10:09 ` Duy Nguyen
2016-12-08 18:55 ` Stefan Beller
2016-12-09 12:46 ` Duy Nguyen
2016-12-09 23:00 ` Brandon Williams
2016-12-09 23:10 ` Stefan Beller
2016-12-08 1:46 ` [PATCHv6 5/7] worktree: add function to check if worktrees are in use Stefan Beller
2016-12-08 10:40 ` Duy Nguyen
2016-12-08 10:51 ` Duy Nguyen
2016-12-08 19:32 ` Stefan Beller
2016-12-08 1:46 ` Stefan Beller [this message]
2016-12-08 1:46 ` [PATCHv6 7/7] submodule: add absorb-git-dir function Stefan Beller
2016-12-08 10:56 ` Duy Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161208014623.7588-7-sbeller@google.com \
--to=sbeller@google.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).