Function: magit-inside-gitdir-p

magit-inside-gitdir-p is a byte-compiled function defined in magit-git.el.

Signature

(magit-inside-gitdir-p &optional NOERROR)

Documentation

Return t if default-directory is below the repository directory.

If it is below the working directory, then return nil. If it isn't below either, then signal an error unless NOERROR is non-nil, in which case return nil.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit-inside-gitdir-p (&optional noerror)
  "Return t if `default-directory' is below the repository directory.
If it is below the working directory, then return nil.
If it isn't below either, then signal an error unless NOERROR
is non-nil, in which case return nil."
  (and (magit--assert-default-directory noerror)
       ;; Below a repository directory that is not located below the
       ;; working directory "git rev-parse --is-inside-git-dir" prints
       ;; "false", which is wrong.
       (let ((gitdir (magit-gitdir)))
         (cond (gitdir (file-in-directory-p default-directory gitdir))
               (noerror nil)
               ((signal 'magit-outside-git-repo default-directory))))))