Function: forge-get-worktree
forge-get-worktree is a byte-compiled function defined in
forge-repo.el.
Signature
(forge-get-worktree REPO)
Documentation
Validate, remember and return a worktree for REPO.
If default-directory is within one of REPO's worktrees, record that
location in its worktree slot and return it. Otherwise, if a worktree
has been recorded before, validate that. If it still is a worktree of
REPO, return it, else set the slot to nil and return nil.
Source Code
;; Defined in ~/.emacs.d/elpa/forge-20260408.1922/forge-repo.el
(defun forge-get-worktree (repo)
"Validate, remember and return a worktree for REPO.
If `default-directory' is within one of REPO's worktrees, record that
location in its `worktree' slot and return it. Otherwise, if a worktree
has been recorded before, validate that. If it still is a worktree of
REPO, return it, else set the slot to nil and return nil."
(cond-let*
([_(forge-repository-equal
repo (forge-get-repository :dir default-directory))]
[current-tree (magit-toplevel)]
(oset repo worktree current-tree))
([saved-tree (oref repo worktree)]
[_(file-accessible-directory-p saved-tree)]
(if (forge-repository-equal repo (forge-get-repository :dir saved-tree))
saved-tree
(oset repo worktree nil)))))