• Duy Nguyen's avatar
    worktree remove: allow it when $GIT_WORK_TREE is already gone · ee6763af
    Duy Nguyen authored
    "git worktree remove" basically consists of two things
    - delete $GIT_WORK_TREE
    - delete $GIT_DIR (which is $SUPER_GIT_DIR/worktrees/something)
    If $GIT_WORK_TREE is already gone for some reason, we should be able
    to finish the job by deleting $GIT_DIR.
    Two notes:
    - $GIT_WORK_TREE _can_ be missing if the worktree is locked. In that
      case we must not delete $GIT_DIR because the real $GIT_WORK_TREE may
      be in a usb stick somewhere. This is already handled because we
      check for lock first.
    - validate_worktree() is still called because it may do more checks in
      future (and it already does something else, like checking main
      worktree, but that's irrelevant in this case)
    Noticed-by: Kaartic Sivaraam's avatarKaartic Sivaraam <kaartic.sivaraam@gmail.com>
    Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
worktree.h 2.98 KB