Function: projectile--git-relativize

projectile--git-relativize is a byte-compiled function defined in projectile.el.

Signature

(projectile--git-relativize PATHS ROOT TOPLEVEL)

Documentation

Return PATHS, given relative to TOPLEVEL, relative to ROOT instead.

Git reports porcelain and diff paths relative to the repository root regardless of where it was run, so a project sitting below that root needs them translated - and anything outside the project dropped.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--git-relativize (paths root toplevel)
  "Return PATHS, given relative to TOPLEVEL, relative to ROOT instead.
Git reports porcelain and diff paths relative to the repository root
regardless of where it was run, so a project sitting below that root
needs them translated - and anything outside the project dropped."
  (if (equal (file-truename root) toplevel)
      paths
    (delq nil
          (mapcar (lambda (path)
                    (let ((absolute (expand-file-name path toplevel))
                          (root (file-truename root)))
                      (when (string-prefix-p root absolute)
                        (file-relative-name absolute root))))
                  paths))))