ArduPilot / ardupilot

ArduPlane, ArduCopter, ArduRover, ArduSub source
http://ardupilot.org/
GNU General Public License v3.0
10.91k stars 17.41k forks source link

ArduPilot's use of submodules and recommended workflow hose the git tree when rebasing on top of master #26039

Open Ryanf55 opened 9 months ago

Ryanf55 commented 9 months ago

Bug report

Issue details

When using git submodules, when they are moved around, it causes major issues when switching branches.

Version

Platform [x ] All [ ] AntennaTracker [ ] Copter [ ] Plane [ ] Rover [ ] Submarine

Steps to reproduce

  1. Start with an empty directory
  2. Clone my repo as origin ryanf55/ardupilot with --recurse-submodules at hash 5c1ed968b18ea196b8376cdd6cc7aeae9b3085c4
  3. Change directory into ardupilot
  4. Add an "upstream" remote of ardupilot/ardupilot
  5. Fetch upstream
  6. Rebase origin on upstream
  7. Congrats, the work tree is hosed

Attempted recovery

Logs

Full logs to reproduce this are attached. log.txt

The exact error occurs here:

ryan@B650-970:~/Dev/tmp_ws/ardupilot$ git rebase upstream/master
fatal: not a git repository: ../../.git/modules/modules/lwip
fatal: could not reset submodule index
error: could not detach HEAD

Recommendations

  1. Add documentation to the wiki on how to switch branches and rebase without error OR
  2. Switch to a different version control tool for dependencies such as Conan, CPM, VCS, Google Repo

References

tridge commented 9 months ago

I just followed your list of steps and had no issues. All steps worked fine here is a log of all steps: http://uav.tridgell.net/tmp/git-test.txt

tridge commented 9 months ago

@Ryanf55 I've now reproduced. The key step which you didn't call out in the description is "git config submodule.recurse true". If you don't do that then it all works fine. I've never set that config option myself, and just use --recurse when I want that (I often don't)

Ryanf55 commented 9 months ago

@Ryanf55 I've now reproduced. The key step which you didn't call out in the description is "git config submodule.recurse true". If you don't do that then it all works fine. I've never set that config option myself, and just use --recurse when I want that (I often don't)

Thanks for looking at this and reproducing the issue!

I'll create a Wiki PR to recommend turning off the submodule.recurse locally in the ArduPilot repo. ^