I managed to corrupt one of my local repositories into thinking a newer submodule commit was associated with several older commits, all created before the submodule commit itself.
This behaviour looks like a great way to silently corrupt one's work state (including, if it happens on a CI/CD server, potentially artifacts built from said state), so I'd consider it of pretty high impact. Unfortunately, I cannot make it happen again.
Three repositories were involved, 'library', 'app A', 'app B'. 'library' is a submodule in both 'app [A|B]' branches.
On each repository, a feature branch existed:
In both 'app-[a|b]-feature' branches, the submodule pointed to library/main at the moment of forking, as the library-feature is a soft dependency. (For testing, I checked out 'library-feature' but never committed it.)
For all commits of my 'app-[a|b]-feature' branches, the submodule commit was 12973e39da77f7efecfa30d016909d8b0c01badc, from the 'main' branch of the 'library'.
I merged my 'library-feature' branch, resulting in a new merge commit on 'main', d0542deed57e204e5ae74795aad77773f72734c0 . Before merging the 'app-[a|b]-feature' branches, I went to update their respective submodule, so they will actually use the library-feature when checked out.
In app A
git checkout maingit pullgit rebase --continuegit diff origin/app-a-feature..HEAD displayed, as expected, exactly the submodule change from 12973e39da77f7efecfa30d016909d8b0c01badc to d0542deed57e204e5ae74795aad77773f72734c0.Here, all had gone well.
In app B
git status showed no changes.git checkout main and git checkout d0542deed57e204e5ae74795aad77773f72734c0, but both concurred: I was already there. So did git log -1 in the submodule and the file changes themselves were also present.git rebase --abort - git status still showed no changes and yet the submodule was still on d0542deed57e204e5ae74795aad77773f72734c0.git status still showed no changes and yet the submodule was still on d0542deed57e204e5ae74795aad77773f72734c0.Somehow I got my index corrupted. Only by re-cloning the 'app B' repository did I manage to resolve the inconsistency - and unfortunately I brainfarted and deleted the original first, so I cannot git bugreport now.
I tried to MVE with local, empty repositories, but these steps do not reproduce the issue:
git init applicationgit init librarycd librarygit commit --allow-empty -m initgit checkout -b library-featuregit commit --allow-empty -m 'feature change'cd ../applicationgit commit --allow-empty -m initgit submodule add -b master ../library library-modulegit commit -m 'add submodule'git commit --allow-empty -m 'unrelated change'cd library-modulegit checkout library-featurecd ..git rebase -i HEAD~1e <hash> unrelated change : emptygit status - submodule change visible and unstagedgit rebase --abortgit status - submodule change visible and unstagedWith my newly cloned real 'app B' repository I then tried to reproduce the original fault "on real data", but this time everything simply worked fine.
