* Fwd: Submodules & worktree
[not found] <CAKQS2drF+CQTiKtXD6Kx1ZbH9ZTekWmbfiiHTCJV_BrT5-gAFQ@mail.gmail.com>
@ 2019-02-01 14:00 ` Ole Pinto
2019-02-01 15:04 ` Mateusz Loskot
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ole Pinto @ 2019-02-01 14:00 UTC (permalink / raw)
To: git
Adding a worktree from a working copy with submodules doesn't work.
In the config file I have
[submodule]
recurse = true
It that's not present, I don't find the problem.
# Preparation
$ git --version
git version 2.20.1
$ cd /tmp/
$ git init main_repo
Initialized empty Git repository in /tmp/main_repo/.git/
$ git init repo_submod
Initialized empty Git repository in /tmp/repo_submod/.git/
$ cd repo_submod
$ echo Some text > file.txt
$ git add file.txt
$ git ci -m "First commit in subrepo"
[master (root-commit) ebc9325] First commit in subrepo
1 file changed, 1 insertion(+)
create mode 100644 file.txt
$ cd ../main_repo/
$ git submodule add /tmp/repo_submod submod
Cloning into '/tmp/main_repo/submod'...
done.
$ git ci -am "First commit, add submodule"
[master (root-commit) 695b3a1] First commit, add submodule
2 files changed, 4 insertions(+)
create mode 100644 .gitmodules
create mode 160000 submod
# Problem 1 (can't run worktree add)
$ git worktree add ../wt -b new_branch
Preparing worktree (new branch 'new_branch')
fatal: exec '--super-prefix=submod/': cd to 'submod' failed: No such
file or directory
error: Submodule 'submod' could not be updated.
error: Submodule 'submod' cannot checkout new HEAD.
fatal: Could not reset index file to revision 'HEAD'.
The new directory (../wt) is created and removed (seen with strace).
The new branch is created and not removed.
# Problem 2 (submodule status seems not to detect some cases)
$ pwd
/tmp/main_repo
$ git submodule status
ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod (heads/master)
$ rm submod/file.txt submod/.git
$ git submodule status
ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod
So, I have a plain, empty directory where the submodule should be. Not
having any 'first char', I'd expect it to be checked out and up to
date. Is this expected?
Thanks a lot for the work!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Submodules & worktree
2019-02-01 14:00 ` Fwd: Submodules & worktree Ole Pinto
@ 2019-02-01 15:04 ` Mateusz Loskot
2020-01-28 3:56 ` Philippe Blain
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Mateusz Loskot @ 2019-02-01 15:04 UTC (permalink / raw)
To: git
On Fri, 1 Feb 2019 at 15:00, Ole Pinto <olepinto@gmail.com> wrote:
>
> Adding a worktree from a working copy with submodules doesn't work.
>
> In the config file I have
> [submodule]
> recurse = true
>
FYI, https://git-scm.com/docs/git-worktree#_bugs
"Multiple checkout in general is still experimental, and the support
for submodules is incomplete.
It is NOT recommended to make multiple checkouts of a superproject."
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Submodules & worktree
2019-02-01 14:00 ` Fwd: Submodules & worktree Ole Pinto
2019-02-01 15:04 ` Mateusz Loskot
@ 2020-01-28 3:56 ` Philippe Blain
2020-01-28 4:01 ` Philippe Blain
2020-01-28 4:01 ` Philippe Blain
3 siblings, 0 replies; 5+ messages in thread
From: Philippe Blain @ 2020-01-28 3:56 UTC (permalink / raw)
To: Ole Pinto; +Cc: Git List, mateusz, Peter Kaestle
Hi Ole,
> Le 1 févr. 2019 à 09:00, Ole Pinto <olepinto@gmail.com> a écrit :
>
> Adding a worktree from a working copy with submodules doesn't work.
>
> In the config file I have
> [submodule]
> recurse = true
>
> It that's not present, I don't find the problem.
I also stumbled upon this bug and fixed it in 4782cf2ab6 (worktree: teach "add" to ignore submodule.recurse config, 2019-10-27), which was merged in 05fc6471e3 (Merge branch 'pb/no-recursive-reset-hard-in-worktree-add', 2019-12-01) and made it to Git 2.25.
`git worktree add` now works correctly in a project with submodules, and cd-ing to the new worktree directory and issuing `git submodule update` inits and clones the submodule(s) to .git/worktrees/<worktree-name>/modules/<submodule-name>, as it should.
I must warn you however that I discovered another bug that can happen with the submodule.recurse config when using worktrees with projects that have submodules. In short, issuing `git checkout` (or `git reset` or `git read-tree`) in one of the worktrees will leave the .git file in the submodule incorrectly pointing to the repository of the submodule in the main worktree, i.e. .git/modules/<submodule-name> instead of .git/worktrees/<worktree-name>/modules/<submodule-name>. I also fixed this bug [1], my patch series for this is currently in next.
[1] https://github.com/gitgitgadget/git/pull/523
> # Problem 2 (submodule status seems not to detect some cases)
>
> $ pwd
> /tmp/main_repo
>
> $ git submodule status
> ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod (heads/master)
>
> $ rm submod/file.txt submod/.git
>
> $ git submodule status
> ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod
>
> So, I have a plain, empty directory where the submodule should be. Not
> having any 'first char', I'd expect it to be checked out and up to
> date. Is this expected?
This is indeed not expected, and used to work correctly (the hash should be prefixed with a ‘-‘) in Git 2.12. This bevaviour regressed when `git submodule status` was ported to C in a9f8a37584 (submodule: port submodule subcommand 'status' from shell to C, 2017-10-06).
Another user reported this regression to the list recently and a patch series is in the works to fix it [2].
[2] https://lore.kernel.org/git/xmqqv9owbw5o.fsf@gitster-ct.c.googlers.com/
Cheers,
Philippe.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Submodules & worktree
2019-02-01 14:00 ` Fwd: Submodules & worktree Ole Pinto
2019-02-01 15:04 ` Mateusz Loskot
2020-01-28 3:56 ` Philippe Blain
@ 2020-01-28 4:01 ` Philippe Blain
2020-01-28 4:01 ` Philippe Blain
3 siblings, 0 replies; 5+ messages in thread
From: Philippe Blain @ 2020-01-28 4:01 UTC (permalink / raw)
To: Ole Pinto; +Cc: Git List, mateusz, Peter Kaestle
Hi Ole,
> Le 1 févr. 2019 à 09:00, Ole Pinto <olepinto@gmail.com> a écrit :
>
> Adding a worktree from a working copy with submodules doesn't work.
>
> In the config file I have
> [submodule]
> recurse = true
>
> It that's not present, I don't find the problem.
I also stumbled upon this bug and fixed it in 4782cf2ab6 (worktree: teach "add" to ignore submodule.recurse config, 2019-10-27), which was merged in 05fc6471e3 (Merge branch 'pb/no-recursive-reset-hard-in-worktree-add', 2019-12-01) and made it to Git 2.25.
`git worktree add` now works correctly in a project with submodules, and cd-ing to the new worktree directory and issuing `git submodule update` inits and clones the submodule(s) to .git/worktrees/<worktree-name>/modules/<submodule-name>, as it should.
I must warn you however that I discovered another bug that can happen with the submodule.recurse config when using worktrees with projects that have submodules. In short, issuing `git checkout` (or `git reset` or `git read-tree`) in one of the worktrees will leave the .git file in the submodule incorrectly pointing to the repository of the submodule in the main worktree, i.e. .git/modules/<submodule-name> instead of .git/worktrees/<worktree-name>/modules/<submodule-name>. I also fixed this bug [1], my patch series for this is currently in next.
[1] https://github.com/gitgitgadget/git/pull/523
> # Problem 2 (submodule status seems not to detect some cases)
>
> $ pwd
> /tmp/main_repo
>
> $ git submodule status
> ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod (heads/master)
>
> $ rm submod/file.txt submod/.git
>
> $ git submodule status
> ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod
>
> So, I have a plain, empty directory where the submodule should be. Not
> having any 'first char', I'd expect it to be checked out and up to
> date. Is this expected?
This is indeed not expected, and used to work correctly (the hash should be prefixed with a ‘-‘) in Git 2.12. This bevaviour regressed when `git submodule status` was ported to C in a9f8a37584 (submodule: port submodule subcommand 'status' from shell to C, 2017-10-06).
Another user reported this regression to the list recently and a patch series is in the works to fix it [2].
[2] https://lore.kernel.org/git/xmqqv9owbw5o.fsf@gitster-ct.c.googlers.com/
Cheers,
Philippe.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Submodules & worktree
2019-02-01 14:00 ` Fwd: Submodules & worktree Ole Pinto
` (2 preceding siblings ...)
2020-01-28 4:01 ` Philippe Blain
@ 2020-01-28 4:01 ` Philippe Blain
3 siblings, 0 replies; 5+ messages in thread
From: Philippe Blain @ 2020-01-28 4:01 UTC (permalink / raw)
To: Ole Pinto; +Cc: Git List, mateusz, Peter Kaestle
Hi Ole,
> Le 1 févr. 2019 à 09:00, Ole Pinto <olepinto@gmail.com> a écrit :
>
> Adding a worktree from a working copy with submodules doesn't work.
>
> In the config file I have
> [submodule]
> recurse = true
>
> It that's not present, I don't find the problem.
I also stumbled upon this bug and fixed it in 4782cf2ab6 (worktree: teach "add" to ignore submodule.recurse config, 2019-10-27), which was merged in 05fc6471e3 (Merge branch 'pb/no-recursive-reset-hard-in-worktree-add', 2019-12-01) and made it to Git 2.25.
`git worktree add` now works correctly in a project with submodules, and cd-ing to the new worktree directory and issuing `git submodule update` inits and clones the submodule(s) to .git/worktrees/<worktree-name>/modules/<submodule-name>, as it should.
I must warn you however that I discovered another bug that can happen with the submodule.recurse config when using worktrees with projects that have submodules. In short, issuing `git checkout` (or `git reset` or `git read-tree`) in one of the worktrees will leave the .git file in the submodule incorrectly pointing to the repository of the submodule in the main worktree, i.e. .git/modules/<submodule-name> instead of .git/worktrees/<worktree-name>/modules/<submodule-name>. I also fixed this bug [1], my patch series for this is currently in next.
[1] https://github.com/gitgitgadget/git/pull/523
> # Problem 2 (submodule status seems not to detect some cases)
>
> $ pwd
> /tmp/main_repo
>
> $ git submodule status
> ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod (heads/master)
>
> $ rm submod/file.txt submod/.git
>
> $ git submodule status
> ebc9325f7b19164c9bdfd05263481ded66d7bd7d submod
>
> So, I have a plain, empty directory where the submodule should be. Not
> having any 'first char', I'd expect it to be checked out and up to
> date. Is this expected?
This is indeed not expected, and used to work correctly (the hash should be prefixed with a ‘-‘) in Git 2.12. This bevaviour regressed when `git submodule status` was ported to C in a9f8a37584 (submodule: port submodule subcommand 'status' from shell to C, 2017-10-06).
Another user reported this regression to the list recently and a patch series is in the works to fix it [2].
[2] https://lore.kernel.org/git/xmqqv9owbw5o.fsf@gitster-ct.c.googlers.com/
Cheers,
Philippe.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-01-28 4:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAKQS2drF+CQTiKtXD6Kx1ZbH9ZTekWmbfiiHTCJV_BrT5-gAFQ@mail.gmail.com>
2019-02-01 14:00 ` Fwd: Submodules & worktree Ole Pinto
2019-02-01 15:04 ` Mateusz Loskot
2020-01-28 3:56 ` Philippe Blain
2020-01-28 4:01 ` Philippe Blain
2020-01-28 4:01 ` Philippe Blain
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).