Function: eca--session-for-worktree
eca--session-for-worktree is a natively compiled function defined in
eca-util.el.
Signature
(eca--session-for-worktree ROOT)
Documentation
Find a session whose workspace shares the same git repo as ROOT.
Returns the session if ROOT is a git worktree (or regular repo) that
shares the same git-common-dir as one of an existing session's
workspace folders AND is not in an ancestor/descendant relationship
with that folder. True git worktrees are always sibling directories,
never nested, so a match where one path contains the other indicates
ROOT is merely a sub- or super-directory of an existing folder rather
than a separate worktree (typical case: $HOME is a dotfiles git repo
and the user starts ECA on a subdirectory, or vice versa). Returns
nil otherwise.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-util.el
(defun eca--session-for-worktree (root)
"Find a session whose workspace shares the same git repo as ROOT.
Returns the session if ROOT is a git worktree (or regular repo) that
shares the same `git-common-dir' as one of an existing session's
workspace folders AND is not in an ancestor/descendant relationship
with that folder. True git worktrees are always sibling directories,
never nested, so a match where one path contains the other indicates
ROOT is merely a sub- or super-directory of an existing folder rather
than a separate worktree (typical case: $HOME is a dotfiles git repo
and the user starts ECA on a subdirectory, or vice versa). Returns
nil otherwise."
(when-let* ((root-common-dir (eca--git-common-dir root)))
(-first (lambda (session)
(--first (when-let* ((folder-common-dir (eca--git-common-dir it)))
(and (string= (file-truename root-common-dir)
(file-truename folder-common-dir))
(not (eca--paths-nested-p root it))))
(eca--session-workspace-folders session)))
(eca-vals eca--sessions))))