Mbed-TLS / mbedtls-docs

Version-independent documentation for Mbed TLS
Apache License 2.0
21 stars 28 forks source link

Scripts to facilitate working with git submodules #140

Open gilles-peskine-arm opened 7 months ago

gilles-peskine-arm commented 7 months ago

Working with Git submodules can be awkward: they aren't always supported separately. We should share scripts to facilitate that.

gilles-peskine-arm commented 7 months ago

For me, on a day-to-day basis, the main problem is that worktrees and submodules aren't really supported together out of the box. I've started to build some tooling around that. It isn't yet mature enough to share in tools/bin, but I'm putting it out there so people can try it out.

Please note that you use these scripts at your own risk. They have worked once on my machine (Ubuntu 22.04). They will probably throw strange errors and leave your working directory in a weird state if you try to use them under unexpected conditions. They probably won't directly erase all your files, but they might cause you to accidentally erase all your files when you try to clean up.

Assumption: you have a “main” worktree of mbedtls /path/to/main, where the framework submodule is checked out. You like to work in other mbedtls worktrees where the framework submodule is a worktree of /path/to/main/framework.

  1. [For zsh users] From /path/to/main, create a new worktree to work on a branch, with submodules being also worktrees: adw.zsh.txt (source this from ~/.zshrc)

  2. [For Linux/Mac users] From an alternative worktree of mbedtls where the submodule is not yet initialized, set up the submodule as a worktree: git-worktree-submodules (make it executable and put it in $PATH)

  3. [For Linux/Mac users] Once you're done with a worktree, clean it up, including its submodules which are also worktrees: git-worktree-rm-r.txt (make it executable and put it in $PATH)