scripts icon indicating copy to clipboard operation
scripts copied to clipboard

sub-sub-modules end up on wrong commit

Open mind-bending-forks opened this issue 7 years ago • 2 comments

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.

mind-bending-forks avatar Sep 25 '18 22:09 mind-bending-forks

This is the same issue as #15, which was never resolved.

jeremysears avatar Sep 26 '18 03:09 jeremysears

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.

jeremysears avatar Sep 26 '18 03:09 jeremysears