From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Stefan Beller" <sbeller@google.com>,
tsniatowski@vewd.com, "Jonathan Nieder" <jrnieder@gmail.com>,
marcnarc@xiplink.com, "Junio C Hamano" <gitster@pobox.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 04/10] submodule init: support multiple worktrees
Date: Wed, 16 Jan 2019 17:31:53 +0700 [thread overview]
Message-ID: <20190116103159.9305-5-pclouds@gmail.com> (raw)
In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com>
The entire submodule section in the superproject will be per-worktree
and written to $GIT_DIR/config.worktree.
The behavior when you only have one worktree (and not enabled
extensions.worktreeConfig) is the same as before, everything is still
written in $GIT_DIR/config
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/submodule--helper.c | 14 +++++---------
t/t2405-worktree-submodules.sh | 28 ++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 7b328ec060..6b749b41fb 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -639,15 +639,11 @@ static void init_submodule(const char *path, const char *prefix,
die(_("No url found for submodule path '%s' in .gitmodules"),
displaypath);
- /*
- * NEEDSWORK: In a multi-working-tree world, this needs to be
- * set in the per-worktree config.
- *
- * Set active flag for the submodule being initialized
- */
+ check_multi_worktree_support();
+
if (!is_submodule_active(the_repository, path)) {
strbuf_addf(&sb, "submodule.%s.active", sub->name);
- git_config_set_gently(sb.buf, "true");
+ repo_config_set_worktree_gently(the_repository, sb.buf, "true");
strbuf_reset(&sb);
}
@@ -672,7 +668,7 @@ static void init_submodule(const char *path, const char *prefix,
free(oldurl);
}
- if (git_config_set_gently(sb.buf, url))
+ if (repo_config_set_worktree_gently(the_repository, sb.buf, url))
die(_("Failed to register url for submodule path '%s'"),
displaypath);
if (!(flags & OPT_QUIET))
@@ -693,7 +689,7 @@ static void init_submodule(const char *path, const char *prefix,
} else
upd = xstrdup(submodule_strategy_to_string(&sub->update_strategy));
- if (git_config_set_gently(sb.buf, upd))
+ if (repo_config_set_worktree_gently(the_repository, sb.buf, upd))
die(_("Failed to register update mode for submodule path '%s'"), displaypath);
}
strbuf_release(&sb);
diff --git a/t/t2405-worktree-submodules.sh b/t/t2405-worktree-submodules.sh
index 3ee5380e88..2ee3e2d039 100755
--- a/t/t2405-worktree-submodules.sh
+++ b/t/t2405-worktree-submodules.sh
@@ -39,4 +39,32 @@ test_expect_success 'add submodules' '
test -d .git/worktrees/secondary/modules/sub2
'
+test_expect_success 'init submodules' '
+ git clone --no-local .git cloned &&
+ (
+ cd cloned &&
+ git config extensions.worktreeConfig true &&
+ git submodule init sub1 &&
+ git worktree add secondary origin/secondary &&
+ cd secondary &&
+ git submodule init sub2
+ ) &&
+
+ git -C cloned config --get-regexp "submodule.*" | sort >actual1 &&
+ cat >expected1 <<-EOF &&
+ submodule.sub1.active true
+ submodule.sub1.url $(pwd)/submodsrc
+ EOF
+ test_cmp expected1 actual1 &&
+ ! test -d cloned/.git/modules/sub1 &&
+
+ git -C cloned/secondary config --get-regexp "submodule.*" | sort >actual2 &&
+ cat >expected2 <<-EOF &&
+ submodule.sub2.active true
+ submodule.sub2.url $(pwd)/submodsrc
+ EOF
+ test_cmp expected2 actual2 &&
+ ! test -d cloned/.git/worktrees/secondary/modules/sub2
+'
+
test_done
--
2.20.0.482.g66447595a7
next prev parent reply other threads:[~2019-01-16 10:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 10:31 [RFC/PATCH 00/10] Support using submodules with worktrees Nguyễn Thái Ngọc Duy
2019-01-16 10:31 ` [PATCH 01/10] doc: about submodule support with multiple worktrees Nguyễn Thái Ngọc Duy
2019-01-16 22:06 ` Stefan Beller
2019-01-17 10:22 ` Duy Nguyen
2019-01-16 10:31 ` [PATCH 02/10] submodule--helper: add missing \n Nguyễn Thái Ngọc Duy
2019-01-16 10:31 ` [PATCH 03/10] submodule add: support multiple worktrees Nguyễn Thái Ngọc Duy
2019-01-16 22:27 ` Stefan Beller
2019-01-16 10:31 ` Nguyễn Thái Ngọc Duy [this message]
2019-01-16 10:31 ` [PATCH 05/10] submodule update: add tests for " Nguyễn Thái Ngọc Duy
2019-01-16 10:31 ` [PATCH 06/10] submodule sync: support " Nguyễn Thái Ngọc Duy
2019-01-16 10:31 ` [PATCH 07/10] submodule deinit: " Nguyễn Thái Ngọc Duy
2019-01-16 10:31 ` [PATCH 08/10] submodule clone: use repo_config_set() Nguyễn Thái Ngọc Duy
2019-01-16 10:31 ` [PATCH 09/10] submodule clone: propagate extensions.worktreeConfig Nguyễn Thái Ngọc Duy
2019-01-16 10:31 ` [PATCH 10/10] submodule ensure-core-worktree: write to config.worktree Nguyễn Thái Ngọc Duy
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190116103159.9305-5-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=marcnarc@xiplink.com \
--cc=sbeller@google.com \
--cc=tsniatowski@vewd.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).