branch: elpa/magit
commit 7fe84a4cd039ffc3db3b29f41f8c9b44092959b7
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit--early-process-lines: New internal helper function
---
lisp/magit-git.el | 67 ++++++++++++++++++++++++++-------------------------
lisp/magit-process.el | 9 ++-----
2 files changed, 36 insertions(+), 40 deletions(-)
diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 13c81e5a682..9d006b4388d 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -94,6 +94,12 @@ this."
:type '(choice (coding-system :tag "Coding system to decode Git output")
(const :tag "Use system default" nil)))
+(defun magit--early-process-lines (program &rest args)
+ "Only used to initialize custom options."
+ (let ((process-environment
+ (append magit-git-environment process-environment)))
+ (apply #'process-lines-ignore-status program args)))
+
(defvar magit-git-w32-path-hack nil
"Alist of (EXE . (PATHENTRY)).
This specifies what additional PATH setting needs to be added to
@@ -105,31 +111,29 @@ successfully.")
;; Avoid the wrappers "cmd/git.exe" and "cmd/git.cmd",
;; which are much slower than using "bin/git.exe" directly.
(and-let ((exec (executable-find "git")))
- (ignore-errors
- ;; Git for Windows 2.x provides cygpath so we can
- ;; ask it for native paths.
- (let* ((core-exe
- (car
- (process-lines
- exec "-c"
- "alias.X=!x() { which \"$1\" | cygpath -mf -; }; x"
- "X" "git")))
- (hack-entry (assoc core-exe magit-git-w32-path-hack))
- ;; Running the libexec/git-core executable
- ;; requires some extra PATH entries.
- (path-hack
- (list (concat "PATH="
- (car (process-lines
- exec "-c"
- "alias.P=!cygpath -wp \"$PATH\""
- "P"))))))
- ;; The defcustom STANDARD expression can be
- ;; evaluated many times, so make sure it is
- ;; idempotent.
- (if hack-entry
- (setcdr hack-entry path-hack)
- (push (cons core-exe path-hack) magit-git-w32-path-hack))
- core-exe))))
+ ;; Git for Windows 2.x provides cygpath so we can
+ ;; ask it for native paths.
+ (let* ((core-exe
+ (car (magit--early-process-lines
+ exec "-c"
+ "alias.X=!x() { which \"$1\" | cygpath -mf -; }; x"
+ "X" "git")))
+ (hack-entry (assoc core-exe magit-git-w32-path-hack))
+ ;; Running the libexec/git-core executable
+ ;; requires some extra PATH entries.
+ (path-hack
+ (list (concat "PATH="
+ (car (magit--early-process-lines
+ exec "-c"
+ "alias.P=!cygpath -wp \"$PATH\""
+ "P"))))))
+ ;; The defcustom STANDARD expression can be
+ ;; evaluated many times, so make sure it is
+ ;; idempotent.
+ (if hack-entry
+ (setcdr hack-entry path-hack)
+ (push (cons core-exe path-hack) magit-git-w32-path-hack))
+ core-exe)))
(and (eq system-type 'darwin)
(executable-find "git"))
"git")
@@ -1208,14 +1212,11 @@ or if no rename is detected."
"Failed to parse Cygwin mount: %S" mount)))
;; If --exec-path is not a native Windows path,
;; then we probably have a cygwin git.
- (let ((process-environment
- (append magit-git-environment
- process-environment)))
- (and (not (string-match-p
- "\\`[a-zA-Z]:"
- (car (process-lines
- magit-git-executable "--exec-path"))))
- (ignore-errors (process-lines "mount")))))
+ (and (not (string-match-p
+ "\\`[a-zA-Z]:"
+ (car (magit--early-process-lines
+ magit-git-executable "--exec-path"))))
+ (magit--early-process-lines "mount")))
#'> :key (pcase-lambda (`(,cyg . ,_win)) (length cyg))))
"Alist of (CYGWIN . WIN32) directory names.
Sorted from longest to shortest CYGWIN name."
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index 7d4cc829a45..093ee838df7 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -119,13 +119,8 @@ displays the text of `magit-process-error-summary'
instead."
"\\`\\(?:\\(?:/.*/\\)?git-credential-\\)?cache\\'" prog)
(or (cadr (member "--socket" args))
(expand-file-name
"~/.git-credential-cache/socket")))))
- ;; Note: `magit-process-file' is not yet defined when
- ;; evaluating this form, so we use `process-lines'.
- (ignore-errors
- (let ((process-environment
- (append magit-git-environment process-environment)))
- (process-lines magit-git-executable
- "config" "--get-all" "credential.helper"))))
+ (magit--early-process-lines
+ magit-git-executable "config" "--get-all" "credential.helper"))
"If non-nil, start a credential cache daemon using this socket.
When using Git's cache credential helper in the normal way, Emacs