scripts
scripts copied to clipboard
sub-sub-modules end up on wrong commit
I have a repo, A, containing a submodule B.
Repo B is on branch B-branch and has a submodule C.
Submodule C in B is at a specific commit, xxxxxxxxxxxxxxx, that happens not to be the head of the master branch for C.
All the repos (A, submodule B and sub-submodule C) are clean, pushed, etc.
I go into submodule B within A and do
$ git submodule status
xxxxxxxxxxxxxxx C
I then go into the root of repo A and do git-submodule-rewrite B B-branch. It is apparently successful, and I get
Submodule merge complete. Push changes after review.
However, when I do git submodule status, I get
yyyyyyyyyyyyyy B/C
and not
xxxxxxxxxxxxxxx B/C
The merge has resulted in the C sub-sub-module moving to the tip of its master branch (which happens to be commit yyyyyyyyyyyyyy), rather than staying where it should be at commit xxxxxxxxxxxxxxx.
This is the same issue as #15, which was never resolved.
It has been a while since I looked at this, but I believe the commit hash is stored in the .gitmodules file. The script has a few places that it reads from that file, so you should be able to use the same technique to checkout the commit you need. Alternatively, git submodule status should give you the commit hash value. Please submit a PR, if you get it working. The behavior you describe is the correct behavior. I just never happened to need that functionality, so I never ran into it.