From 71e5473493612f74244e2fa7a257a868df98be53 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 19 Sep 2022 16:34:50 +0000 Subject: refs: unify parse_worktree_ref() and ref_type() The logic to handle worktree refs (worktrees/NAME/REF and main-worktree/REF) existed in two places: * ref_type() in refs.c * parse_worktree_ref() in worktree.c Collapse this logic together in one function parse_worktree_ref(): this avoids having to cross-check the result of parse_worktree_ref() and ref_type(). Introduce enum ref_worktree_type, which is slightly different from enum ref_type. The latter is a misleading name (one would think that 'ref_type' would have the symref option). Instead, enum ref_worktree_type only makes explicit how a refname relates to a worktree. From this point of view, HEAD and refs/bisect/abc are the same: they specify the current worktree implicitly. The files-backend must avoid packing refs/bisect/* and friends into packed-refs, so expose is_per_worktree_ref() separately. Signed-off-by: Han-Wen Nienhuys Signed-off-by: Junio C Hamano --- worktree.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'worktree.h') diff --git a/worktree.h b/worktree.h index e9e839926b..9dcea6fc8c 100644 --- a/worktree.h +++ b/worktree.h @@ -166,16 +166,6 @@ const char *worktree_git_path(const struct worktree *wt, const char *fmt, ...) __attribute__((format (printf, 2, 3))); -/* - * Parse a worktree ref (i.e. with prefix main-worktree/ or - * worktrees/) and return the position of the worktree's name and - * length (or NULL and zero if it's main worktree), and ref. - * - * All name, name_length and ref arguments could be NULL. - */ -int parse_worktree_ref(const char *worktree_ref, const char **name, - int *name_length, const char **ref); - /* * Return a refname suitable for access from the current ref store. */ -- cgit v1.3-5-g9baa