Re: [PATCH 7/8] worktree: generalize candidate worktree path validation
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 8, 2020, 22:02 UTC
- Message-ID
- <xmqqimg1jjx8.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200608062356.40264-8-sunshine@sunshineco.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 7 quoted lines
> "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.Makes sense.
Show 5 quoted lines
> - validate_worktree_add(path, opts); > + worktrees = get_worktrees(0); > + check_candidate_path(path, opts->force, worktrees, "add"); > + free_worktrees(worktrees); > + worktrees = NULL;
It is somewhat unsatisfying that the libified helper still signals its displeasure by dying, but a faithful conversion that can be cleaned up later (if we wanted to) like this step is easier to reason about.