worktree: introduce is_shared_symref()

Add a new function, is_shared_symref(), which contains the heart of
find_shared_symref().  Refactor find_shared_symref() to use the new
function is_shared_symref().

Soon, we will use is_shared_symref() to search for symref beyond
the first worktree that matches.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Rubén Justo
2023-02-25 15:21:51 +01:00
committed by Junio C Hamano
parent 56c8fb1e95
commit 662078caac
2 changed files with 37 additions and 31 deletions

View File

@ -149,6 +149,12 @@ const struct worktree *find_shared_symref(struct worktree **worktrees,
const char *symref,
const char *target);
/*
* Returns true if a symref points to a ref in a worktree.
*/
int is_shared_symref(const struct worktree *wt,
const char *symref, const char *target);
/*
* Similar to head_ref() for all HEADs _except_ one from the current
* worktree, which is covered by head_ref().