2022-08-07 16:39:08 +00:00
|
|
|
;;; lisp/lib/git.el -*- lexical-binding: t; -*-
|
2022-09-07 22:08:54 +00:00
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
2022-08-07 16:39:08 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom-git-toplevel (&rest segments)
|
|
|
|
"Return the path to the current repo's root."
|
|
|
|
(cl-destructuring-bind (code . output)
|
|
|
|
(doom-call-process "git" "rev-parse" "--show-toplevel")
|
|
|
|
(if (zerop code)
|
|
|
|
(apply #'file-name-concat output segments)
|
|
|
|
;; TODO throw stderr as error
|
|
|
|
(user-error "Not in a git repo: %s" default-directory))))
|
2022-09-07 22:08:54 +00:00
|
|
|
|
|
|
|
(provide 'doom-lib '(git))
|
|
|
|
;;; git.el ends here
|