From 3b789752a30419535b328c605957b6b43a9d47fa Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 2 May 2022 02:11:52 +0200 Subject: [PATCH] fix: user/system git config breaking straight installer Fix: #6346 --- core/core-packages.el | 140 ++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 68 deletions(-) diff --git a/core/core-packages.el b/core/core-packages.el index f1eac4f4f..a3a2dbd5a 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -111,76 +111,80 @@ uses a straight or package.el command directly).") ;;; Bootstrappers (defun doom--ensure-straight (recipe pin) - (let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el")) - (repo-url (concat "http" (if gnutls-verify-error "s") - "://github.com/" - (or (plist-get recipe :repo) "raxod502/straight.el"))) - (branch (or (plist-get recipe :branch) straight-repository-branch)) - (call (if doom-debug-p + (letenv! (("GIT_CONFIG" nil) + ("GIT_CONFIG_NOSYSTEM" "1") + ("GIT_CONFIG_GLOBAL" (or (getenv "DOOMGITCONFIG") + "/dev/null"))) + (let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el")) + (repo-url (concat "http" (if gnutls-verify-error "s") + "://github.com/" + (or (plist-get recipe :repo) "raxod502/straight.el"))) + (branch (or (plist-get recipe :branch) straight-repository-branch)) + (call (if doom-debug-p + (lambda (&rest args) + (print! "%s" (cdr (apply #'doom-call-process args)))) (lambda (&rest args) - (print! "%s" (cdr (apply #'doom-call-process args)))) - (lambda (&rest args) - (apply #'doom-call-process args))))) - (unless (file-directory-p repo-dir) - (save-match-data - (unless (executable-find "git") - (user-error "Git isn't present on your system. Cannot proceed.")) - (let* ((version (cdr (doom-call-process "git" "version"))) - (version - (and (string-match "\\_<[0-9]+\\.[0-9]+\\(\\.[0-9]+\\)\\_>" version) - (match-string 0 version)))) - (if version - (when (version< version "2.23") - (user-error "Git %s detected! Doom requires git 2.23 or newer!" - version))))) - (print! (start "Installing straight...")) - (print-group! - (cl-destructuring-bind (depth . options) - (doom-enlist straight-vc-git-default-clone-depth) - (let ((branch-switch (if (memq 'single-branch options) - "--single-branch" - "--no-single-branch"))) - (cond - ((eq 'full depth) - (funcall call "git" "clone" "--origin" "origin" - branch-switch repo-url repo-dir)) - ((integerp depth) - (if (null pin) - (progn - (when (file-directory-p repo-dir) - (delete-directory repo-dir 'recursive)) - (funcall call "git" "clone" "--origin" "origin" repo-url - "--no-checkout" repo-dir + (apply #'doom-call-process args))))) + (unless (file-directory-p repo-dir) + (save-match-data + (unless (executable-find "git") + (user-error "Git isn't present on your system. Cannot proceed.")) + (let* ((version (cdr (doom-call-process "git" "version"))) + (version + (and (string-match "\\_<[0-9]+\\.[0-9]+\\(\\.[0-9]+\\)\\_>" version) + (match-string 0 version)))) + (if version + (when (version< version "2.23") + (user-error "Git %s detected! Doom requires git 2.23 or newer!" + version))))) + (print! (start "Installing straight...")) + (print-group! + (cl-destructuring-bind (depth . options) + (doom-enlist straight-vc-git-default-clone-depth) + (let ((branch-switch (if (memq 'single-branch options) + "--single-branch" + "--no-single-branch"))) + (cond + ((eq 'full depth) + (funcall call "git" "clone" "--origin" "origin" + branch-switch repo-url repo-dir)) + ((integerp depth) + (if (null pin) + (progn + (when (file-directory-p repo-dir) + (delete-directory repo-dir 'recursive)) + (funcall call "git" "clone" "--origin" "origin" repo-url + "--no-checkout" repo-dir + "--depth" (number-to-string depth) + branch-switch + "--no-tags" + "--branch" straight-repository-branch)) + (make-directory repo-dir 'recursive) + (let ((default-directory repo-dir)) + (funcall call "git" "init") + (funcall call "git" "branch" "-m" straight-repository-branch) + (funcall call "git" "remote" "add" "origin" repo-url + "--master" straight-repository-branch) + (funcall call "git" "fetch" "origin" pin "--depth" (number-to-string depth) - branch-switch - "--no-tags" - "--branch" straight-repository-branch)) - (make-directory repo-dir 'recursive) - (let ((default-directory repo-dir)) - (funcall call "git" "init") - (funcall call "git" "branch" "-m" straight-repository-branch) - (funcall call "git" "remote" "add" "origin" repo-url - "--master" straight-repository-branch) - (funcall call "git" "fetch" "origin" pin - "--depth" (number-to-string depth) - "--no-tags") - (funcall call "git" "reset" "--hard" pin))))))))) - (require 'straight (concat repo-dir "/straight.el")) - (doom-log "Initializing recipes") - (mapc #'straight-use-recipes - '((org-elpa :local-repo nil) - (melpa :type git :host github - :repo "melpa/melpa" - :build nil) - (gnu-elpa-mirror :type git :host github - :repo "emacs-straight/gnu-elpa-mirror" - :build nil) - (el-get :type git :host github - :repo "dimitri/el-get" - :build nil) - (emacsmirror-mirror :type git :host github - :repo "emacs-straight/emacsmirror-mirror" - :build nil))))) + "--no-tags") + (funcall call "git" "reset" "--hard" pin))))))))) + (require 'straight (concat repo-dir "/straight.el")) + (doom-log "Initializing recipes") + (mapc #'straight-use-recipes + '((org-elpa :local-repo nil) + (melpa :type git :host github + :repo "melpa/melpa" + :build nil) + (gnu-elpa-mirror :type git :host github + :repo "emacs-straight/gnu-elpa-mirror" + :build nil) + (el-get :type git :host github + :repo "dimitri/el-get" + :build nil) + (emacsmirror-mirror :type git :host github + :repo "emacs-straight/emacsmirror-mirror" + :build nil)))))) (defun doom--ensure-core-packages (packages) (doom-log "Installing core packages")