worktree: add utility to find worktree by pathname
find_worktree() employs heuristics to match user provided input -- which may be a pathname or some sort of shorthand -- with an actual worktree. Although this convenience allows a user to identify a worktree with minimal typing, the black-box nature of these heuristics makes it potentially difficult for callers which already know the exact path of a worktree to be confident that the correct worktree will be returned for any specific pathname (particularly a relative one), especially as the heuristics are enhanced and updated. Therefore, add a companion function, find_worktree_by_path(), which deterministically identifies a worktree strictly by pathname with no interpretation and no magic matching. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a80c4c2214
commit
bb4995fc3f
@ -61,6 +61,12 @@ struct worktree *find_worktree(struct worktree **list,
|
||||
const char *prefix,
|
||||
const char *arg);
|
||||
|
||||
/*
|
||||
* Return the worktree corresponding to `path`, or NULL if no such worktree
|
||||
* exists.
|
||||
*/
|
||||
struct worktree *find_worktree_by_path(struct worktree **, const char *path);
|
||||
|
||||
/*
|
||||
* Return true if the given worktree is the main one.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user