worktree: allow to (re)move worktrees with uninitialized submodules
commit00a6d4d1d2260a07ca1372acfae692d9821f165f
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 5 Jan 2019 05:08:40 +0000 (5 12:08 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Jan 2019 17:26:33 +0000 (7 09:26 -0800)
tree1c0ba30f272a8de966af9762c3648004a4b80558
parentb21ebb671bb7dea8d342225f0d66c41f4e54d5ca
worktree: allow to (re)move worktrees with uninitialized submodules

Uninitialized submodules have nothing valueable for us to be worried
about. They are just SHA-1. Let "worktree remove" and "worktree move"
continue in this case so that people can still use multiple worktrees
on repos with optional submodules that are never populated, like
sha1collisiondetection in git.git when checked out by doc-diff script.

Note that for "worktree remove", it is possible that a user
initializes a submodule (*), makes some commits (but not push), then
deinitializes it. At that point, the submodule is unpopulated, but the
precious new commits are still in

    $GIT_COMMON_DIR/worktrees/<worktree>/modules/<submodule>

directory and we should not allow removing the worktree or we lose
those commits forever. The new directory check is added to prevent
this.

(*) yes they are screwed anyway by doing this since "git submodule"
    would add submodule.* in $GIT_COMMON_DIR/config, which is shared
    across multiple worktrees. But it does not mean we let them be
    screwed even more.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/worktree.c
t/t2028-worktree-move.sh