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 07/10] submodule deinit: support multiple worktrees
Date: Wed, 16 Jan 2019 17:31:56 +0700 [thread overview]
Message-ID: <20190116103159.9305-8-pclouds@gmail.com> (raw)
In-Reply-To: <20190116103159.9305-1-pclouds@gmail.com>
This is the reverse of 'init' or 'add', config from superproject is
removed from config.worktree (or just config in standard single
worktree setup)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/submodule--helper.c | 8 ++++++--
t/t2405-worktree-submodules.sh | 11 +++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 288858af83..8943127ae7 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1097,6 +1097,8 @@ static void deinit_submodule(const char *path, const char *prefix,
struct strbuf sb_config = STRBUF_INIT;
char *sub_git_dir = xstrfmt("%s/.git", path);
+ check_multi_worktree_support();
+
sub = submodule_from_path(the_repository, &null_oid, path);
if (!sub || !sub->name)
@@ -1150,21 +1152,23 @@ static void deinit_submodule(const char *path, const char *prefix,
displaypath);
cp_config.git_cmd = 1;
- argv_array_pushl(&cp_config.args, "config", "--get-regexp", NULL);
+ argv_array_pushl(&cp_config.args, "config", "--worktree", "--get-regexp", NULL);
argv_array_pushf(&cp_config.args, "submodule.%s\\.", sub->name);
/* remove the .git/config entries (unless the user already did it) */
if (!capture_command(&cp_config, &sb_config, 0) && sb_config.len) {
+ char *config_file = get_worktree_config(the_repository);
char *sub_key = xstrfmt("submodule.%s", sub->name);
/*
* remove the whole section so we have a clean state when
* the user later decides to init this submodule again
*/
- git_config_rename_section_in_file(NULL, sub_key, NULL);
+ git_config_rename_section_in_file(config_file, sub_key, NULL);
if (!(flags & OPT_QUIET))
printf(_("Submodule '%s' (%s) unregistered for path '%s'\n"),
sub->name, sub->url, displaypath);
free(sub_key);
+ free(config_file);
}
cleanup:
diff --git a/t/t2405-worktree-submodules.sh b/t/t2405-worktree-submodules.sh
index 55daace672..8d53f639c9 100755
--- a/t/t2405-worktree-submodules.sh
+++ b/t/t2405-worktree-submodules.sh
@@ -111,4 +111,15 @@ test_expect_success 'reset sync submodules' '
git -C secondary submodule sync
'
+test_expect_success 'deinit submodules' '
+ git submodule deinit sub1 &&
+ git -C secondary submodule deinit sub2 &&
+ git config --get-regexp "submodule.*" | sort >actual1 &&
+ test_must_be_empty actual1 &&
+ test -d .git/modules/sub1 &&
+ git -C secondary config --get-regexp "submodule.*" | sort >actual2 &&
+ test_must_be_empty actual2 &&
+ test -d .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 ` [PATCH 04/10] submodule init: " Nguyễn Thái Ngọc Duy
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 ` Nguyễn Thái Ngọc Duy [this message]
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-8-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).