From 41af65651d4333cd19ab4af3509fa2d08f3816ed Mon Sep 17 00:00:00 2001 From: David Turner Date: Mon, 10 Aug 2015 13:52:44 -0400 Subject: worktrees: add find_shared_symref Add a new function, find_shared_symref, which contains the heart of die_if_checked_out, but works for any symref, not just HEAD. Refactor die_if_checked_out to use the same infrastructure as find_shared_symref. Soon, we will use find_shared_symref to protect notes merges in worktrees. Signed-off-by: David Turner Reviewed-by: Johan Herland Signed-off-by: Junio C Hamano --- branch.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'branch.h') diff --git a/branch.h b/branch.h index 58aa45fe72..d3446ed73c 100644 --- a/branch.h +++ b/branch.h @@ -59,4 +59,12 @@ extern int read_branch_desc(struct strbuf *, const char *branch_name); */ extern void die_if_checked_out(const char *branch); +/* + * Check if a per-worktree symref points to a ref in the main worktree + * or any linked worktree, and return the path to the exising worktree + * if it is. Returns NULL if there is no existing ref. The caller is + * responsible for freeing the returned path. + */ +extern char *find_shared_symref(const char *symref, const char *target); + #endif -- cgit v1.2.3