On Wed, Nov 30, 2016 at 10:04 AM, Stefan Beller <sbeller@xxxxxxxxxx> wrote: >> Submodules and worktrees seem to have many things in common. > > Yes. :) I moved the code to dir.{c,h} and renamed it to a more generic "move_gitdir", but then I am thinking further about how to align worktrees and submodules here, specifically the recursive part. Whenever submodules and recursion is involved so far we spawned off a child process to take care of the issue in the submodule itself. Here we followed the same pattern and called the submodule--helper to embed the git dirs in the submodule recursively. As this function is not supposed to be submodule specific anymore, I'd rather not want to have the recursive childrens code live inside the submodule helper, so we also need a neutral helper for moving git directories? So there are a couple ways forward: * We declare the "recursive" flag to be submodule specific and keep the recursion in the submodule helper * the recursive flag is generic enough and we invent a plumbing helper. Analogous to the submodule--helper, that was originally invented as a C aid for the git-submodule shell script, we could have a "git--helper" or just "git plumbing <subcmd>", though that sounds like reinventing the wheel as traditionally we'd just have a top level command to do a specific thing. (side note: Some parts of git-rev-parse could go into such a plumbing command) For now I'd think to declare recursion in this function to be submodule specific. Stefan