aboutsummaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-11-03 15:32:34 -0800
committerJunio C Hamano <gitster@pobox.com>2015-11-03 15:32:35 -0800
commit1bf986bc9c1e823da27465bfd9faf2b725bbcc09 (patch)
treeb47aa7c235ebf2bf958f7906e58a0750a418f0db /setup.c
parentc1324e66d44b7d58915cd7e61c1ea85ed3db6a58 (diff)
parent11f9dd719104a960d3e2b478477d9055141d1dbc (diff)
downloadgit-1bf986bc9c1e823da27465bfd9faf2b725bbcc09.tar.gz
git-1bf986bc9c1e823da27465bfd9faf2b725bbcc09.tar.xz
Merge branch 'mk/submodule-gitdir-path' into maint
The submodule code has been taught to work better with separate work trees created via "git worktree add". * mk/submodule-gitdir-path: path: implement common_dir handling in git_pathdup_submodule() submodule refactor: use strbuf_git_path_submodule() in add_submodule_odb()
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/setup.c b/setup.c
index 3324014cb..1a374f2bf 100644
--- a/setup.c
+++ b/setup.c
@@ -230,14 +230,21 @@ void verify_non_filename(const char *prefix, const char *arg)
int get_common_dir(struct strbuf *sb, const char *gitdir)
{
+ const char *git_env_common_dir = getenv(GIT_COMMON_DIR_ENVIRONMENT);
+ if (git_env_common_dir) {
+ strbuf_addstr(sb, git_env_common_dir);
+ return 1;
+ } else {
+ return get_common_dir_noenv(sb, gitdir);
+ }
+}
+
+int get_common_dir_noenv(struct strbuf *sb, const char *gitdir)
+{
struct strbuf data = STRBUF_INIT;
struct strbuf path = STRBUF_INIT;
- const char *git_common_dir = getenv(GIT_COMMON_DIR_ENVIRONMENT);
int ret = 0;
- if (git_common_dir) {
- strbuf_addstr(sb, git_common_dir);
- return 1;
- }
+
strbuf_addf(&path, "%s/commondir", gitdir);
if (file_exists(path.buf)) {
if (strbuf_read_file(&data, path.buf, 0) <= 0)