On Wed, Nov 30, 2016 at 12:51 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote: > Duy Nguyen <pclouds@xxxxxxxxx> writes: > >> On Wed, Nov 23, 2016 at 2:22 AM, Stefan Beller <sbeller@xxxxxxxxxx> wrote: >>> +/* >>> + * Migrate the given submodule (and all its submodules recursively) from >>> + * having its git directory within the working tree to the git dir nested >>> + * in its superprojects git dir under modules/. >>> + */ >>> +void migrate_submodule_gitdir(const char *prefix, const char *path, >>> + int recursive) >> >> Submodules and worktrees seem to have many things in common. The first >> one is this. "git worktree move" on a worktree that contains >> submodules .git also benefits from something like this [1]. I suggest >> you move this function to some neutral place and maybe rename it to >> relocate_gitdir() or something. > > Yeah, good suggestion (including name; first round used "intern" I > had trouble with, then "embed" which was OK-ish, but probably > "relocate" is better choice. If anything, what Stefan's series adds > is a command to un-embed embedded one). Heh, good counter perspective. I thought about embedding it "into the superprojects git directory" whereas your un-embed sounds like you'd assume embedding is targetd towards the working dir. relocate as a fancy name for move sounds like it expects 2 arguments (source and destination), but maybe we could go with: git relocate-git-dir (--into-workingtree|--into-gitdir) \ [--recurse-submodules] \ [--only-fix-gitfile-links-and-core-setting-as-I-moved-it-myself-already] \ [--dryrun] [--verbose] [--unsafe-move] No need to have a pathspec here IMHO. Later it could have another flag to specify the "main" worktree or such as well.