Function: projectile-worktrees-from-jj

projectile-worktrees-from-jj is a byte-compiled function defined in projectile.el.

Signature

(projectile-worktrees-from-jj ROOT)

Documentation

Return the Jujutsu workspaces of the project at ROOT.

Gated on a .jj directory rather than on projectile-project-vcs answering jj, because a colocated repository (jj git init --colocate) holds both markers and is reported as git by default - see projectile-vcs-markers. Such a repository has git worktrees *and* Jujutsu workspaces, and both belong on the list.

The workspace root is asked for through a template. Jujutsu only started recording it in 0.38: an older *workspace* renders as nothing and is skipped rather than becoming a bogus candidate, while an older *binary* rejects the template outright and simply reports nothing.

The remote check comes first, before anything touches the file system, so that a remote project costs no TRAMP round trip.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-worktrees-from-jj (root)
  "Return the Jujutsu workspaces of the project at ROOT.

Gated on a `.jj' directory rather than on `projectile-project-vcs'
answering `jj', because a colocated repository (`jj git init --colocate')
holds both markers and is reported as git by default - see
`projectile-vcs-markers'.  Such a repository has git worktrees *and*
Jujutsu workspaces, and both belong on the list.

The workspace root is asked for through a template.  Jujutsu only started
recording it in 0.38: an older *workspace* renders as nothing and is
skipped rather than becoming a bogus candidate, while an older *binary*
rejects the template outright and simply reports nothing.

The remote check comes first, before anything touches the file system,
so that a remote project costs no TRAMP round trip."
  (when-let* (((not (file-remote-p root)))
              ((file-directory-p (expand-file-name ".jj" root)))
              ((executable-find "jj"))
              (output (projectile--jj root "workspace" "list"
                                      "-T" "self.name() ++ \"\\t\" ++ self.root() ++ \"\\n\"")))
    (delq nil
          (mapcar (lambda (line)
                    ;; Only the name is escaped and quoted by jj, so a tab
                    ;; in the output can only have come from the path -
                    ;; hence splitting once, at the first one.
                    (let* ((parts (split-string line "\t"))
                           (name (car parts))
                           (path (string-join (cdr parts) "\t")))
                      (unless (string-empty-p path)
                        (list :path (file-name-as-directory path)
                              ;; A name that isn't a bare identifier comes
                              ;; back quoted; the quotes aren't part of it.
                              :label (string-trim name "\"" "\"")))))
                  (split-string output "\n" t)))))