worktree: generalize candidate worktree path validation
authorEric Sunshine <sunshine@sunshineco.com>
Wed, 10 Jun 2020 06:30:48 +0000 (02:30 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Jun 2020 17:54:49 +0000 (10:54 -0700)
commitd179af679bd5f70506732e1c9242d367efc7ea42
treeafc5747f0f4e12abff349799be4261180e12b196
parent916133ef8edcda54b0bff03a949c0858cd8d3280
worktree: generalize candidate worktree path validation

"git worktree add" checks that the specified path is a valid location
for a new worktree by ensuring that the path does not already exist and
is not already registered to another worktree (a path can be registered
but missing, for instance, if it resides on removable media). Since "git
worktree add" is not the only command which should perform such
validation ("git worktree move" ought to also), generalize the the
validation function for use by other callers, as well.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/worktree.c