* merge branch with updated submodule leaves repo in modified state
@ 2019-12-10 19:48 Daniel Bosk
2019-12-11 0:51 ` Elijah Newren
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Bosk @ 2019-12-10 19:48 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 1912 bytes --]
Hi all!
`git merge`: if a submodule is updated in the merged branch, the new
version is not checked out after the merge. Is this correct behaviour?
`git switch` correctly updates the submodules when switching between the
branches. I would expect `git merge` to leave the things in the most
up-to-date state.
I tested this with the following settings.
$ git version
git version 2.24.0
$ git config -l
push.default=matching
diff.submodule=log
diff.colorwords=true
diff.algorithm=minimal
diff.exit-code=true
commit.gpgsign=true
submodule.fetchjobs=0
submodule.recurse=true
log.follow=true
MWE:
```
mkdir repoA repoB
# init repos with READMEs
cd repoA
git init
echo "A" > README
git add README
git commit -m "Adds repoA README" README
cd ../repoB
git init
echo "B" > README
git add README
git commit -m "Adds repoB README" README
# construct nested structure: repoA/repoB
cd ../repoA
git submodule add ../repoB/.git
git commit -m "Adds repoB submodule"
# update repoB in branch
git switch -c update-repoB-submodule
cd repoB
echo "B updated" > README
git commit -m "Updates repoB README" README
cd ..
git commit -m "Updates repoB submodule" repoB
```
Now, doing `git switch master` will have the correct version of repoB,
where `cat repoB/README` outputs "B". A `git switch update-repoB-submodule`
from there will yield `cat repoB/README` output "B updated".
However, switching to master and then merging will leave repoB at the
old commit:
```
git switch master
git merge update-repoB-submodule
```
A `git status` says there are new commits in repoB, it's actually a
rewind which excludes the new commit (changing `repoB/README`), so `cat
repoB/README` outputs "B" instead of "B updated". It feels unintended to
get a repo which is in a modified state after a clean merge. Bug?
Cheers,
Daniel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: merge branch with updated submodule leaves repo in modified state
2019-12-10 19:48 merge branch with updated submodule leaves repo in modified state Daniel Bosk
@ 2019-12-11 0:51 ` Elijah Newren
2019-12-11 9:14 ` Daniel Bosk
0 siblings, 1 reply; 3+ messages in thread
From: Elijah Newren @ 2019-12-11 0:51 UTC (permalink / raw)
To: Daniel Bosk; +Cc: Git Mailing List
On Tue, Dec 10, 2019 at 11:58 AM Daniel Bosk <dbosk@kth.se> wrote:
>
> Hi all!
>
> `git merge`: if a submodule is updated in the merged branch, the new
> version is not checked out after the merge. Is this correct behaviour?
>
> `git switch` correctly updates the submodules when switching between the
> branches. I would expect `git merge` to leave the things in the most
> up-to-date state.
>
> I tested this with the following settings.
>
> $ git version
> git version 2.24.0
>
> $ git config -l
> push.default=matching
> diff.submodule=log
> diff.colorwords=true
> diff.algorithm=minimal
> diff.exit-code=true
> commit.gpgsign=true
> submodule.fetchjobs=0
> submodule.recurse=true
> log.follow=true
>
> MWE:
>
> ```
> mkdir repoA repoB
>
> # init repos with READMEs
> cd repoA
> git init
> echo "A" > README
> git add README
> git commit -m "Adds repoA README" README
>
> cd ../repoB
> git init
> echo "B" > README
> git add README
> git commit -m "Adds repoB README" README
>
> # construct nested structure: repoA/repoB
> cd ../repoA
> git submodule add ../repoB/.git
> git commit -m "Adds repoB submodule"
>
> # update repoB in branch
> git switch -c update-repoB-submodule
> cd repoB
> echo "B updated" > README
> git commit -m "Updates repoB README" README
> cd ..
> git commit -m "Updates repoB submodule" repoB
> ```
>
> Now, doing `git switch master` will have the correct version of repoB,
> where `cat repoB/README` outputs "B". A `git switch update-repoB-submodule`
> from there will yield `cat repoB/README` output "B updated".
>
> However, switching to master and then merging will leave repoB at the
> old commit:
> ```
> git switch master
> git merge update-repoB-submodule
> ```
> A `git status` says there are new commits in repoB, it's actually a
> rewind which excludes the new commit (changing `repoB/README`), so `cat
> repoB/README` outputs "B" instead of "B updated". It feels unintended to
> get a repo which is in a modified state after a clean merge. Bug?
Don't know where it falls on the spectrum from bug to unimplemented
feature, but it's certainly a known issue. The last time I remember
discussing this was here:
https://lore.kernel.org/git/CABPp-BHDrw_dAESic3xK7kC3jMgKeNQuPQF69OpbVYhRkbhJsw@mail.gmail.com/
Hope that helps,
Elijah
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: merge branch with updated submodule leaves repo in modified state
2019-12-11 0:51 ` Elijah Newren
@ 2019-12-11 9:14 ` Daniel Bosk
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Bosk @ 2019-12-11 9:14 UTC (permalink / raw)
To: Elijah Newren; +Cc: Git Mailing List
[-- Attachment #1: Type: text/plain, Size: 423 bytes --]
On Tue 10 Dec 2019 16:51:46 GMT, Elijah Newren wrote:
> Don't know where it falls on the spectrum from bug to unimplemented
> feature, but it's certainly a known issue. The last time I remember
> discussing this was here:
>
> https://lore.kernel.org/git/CABPp-BHDrw_dAESic3xK7kC3jMgKeNQuPQF69OpbVYhRkbhJsw@mail.gmail.com/
>
>
> Hope that helps,
Definitely, thanks a lot for the pointer!
Daniel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-11 9:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 19:48 merge branch with updated submodule leaves repo in modified state Daniel Bosk
2019-12-11 0:51 ` Elijah Newren
2019-12-11 9:14 ` Daniel Bosk
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).