Function: magit-git-repo-p

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

Signature

(magit-git-repo-p DIRECTORY &optional NON-BARE)

Documentation

Return t if DIRECTORY is a Git repository.

When optional NON-BARE is non-nil also return nil if DIRECTORY is a bare repository.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit-git-repo-p (directory &optional non-bare)
  "Return t if DIRECTORY is a Git repository.
When optional NON-BARE is non-nil also return nil if DIRECTORY is
a bare repository."
  (and (file-directory-p directory) ; Avoid archives, see #3397.
       (or (file-regular-p (expand-file-name ".git" directory))
           (file-directory-p (expand-file-name ".git" directory))
           (and (not non-bare)
                (file-regular-p (expand-file-name "HEAD" directory))
                (file-directory-p (expand-file-name "refs" directory))
                (file-directory-p (expand-file-name "objects" directory))))))