Function: magit-read-worktree-directory-sibling

magit-read-worktree-directory-sibling is a byte-compiled function defined in magit-worktree.el.

Signature

(magit-read-worktree-directory-sibling PROMPT COMMIT)

Documentation

Call read-directory-name in parent directory of current worktree.

For read-directory-names INITIAL argument use a string based on the name of the current worktree and BRANCH. Use "PREFIX_BRANCH" where PREFIX is the name of the current worktree, up to the first underscore, and slashes in COMMIT are replaced with dashes. If COMMIT is nil use just "PREFIX_". Always forward PROMPT as-is.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260822.1158/magit-worktree.el
(defun magit-read-worktree-directory-sibling (prompt commit)
  "Call `read-directory-name' in parent directory of current worktree.
For `read-directory-name's INITIAL argument use a string based on the
name of the current worktree and BRANCH.  Use \"PREFIX_BRANCH\" where
PREFIX is the name of the current worktree, up to the first underscore,
and slashes in COMMIT are replaced with dashes.  If COMMIT is nil use
just \"PREFIX_\".  Always forward PROMPT as-is."
  (let* ((path (directory-file-name default-directory))
         (name (file-name-nondirectory path)))
    (read-directory-name
     prompt (file-name-directory path) nil nil
     (concat (if (string-match "_" name)
                 (substring name 0 (match-beginning 0))
               name)
             "_"
             (and commit (string-replace "/" "-" commit))))))