emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit 77255776cb 1/4: git-commit: Use magit-git-execu


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 77255776cb 1/4: git-commit: Use magit-git-executable function if available
Date: Mon, 21 Feb 2022 01:58:05 -0500 (EST)

branch: elpa/git-commit
commit 77255776cb38f08bf4b2a5c6c4d3b96c60803312
Author: Kyle Meyer <kyle@kyleam.com>
Commit: Kyle Meyer <kyle@kyleam.com>

    git-commit: Use magit-git-executable function if available
    
    Three spots in git-commit.el hard code "git" as the git executable.
    Two of these spots are in git-commit-self-ident.  If the user doesn't
    have git in $PATH, these spots aren't much of a problem because 1)
    these calls are wrapped with ignore-errors and have fallback values
    and 2) their only callers are some of the git-commit-* "insert header"
    commands.
    
    The "git" in git-commit-setup-font-lock, on the other hand, can cause
    committing to fail if git isn't in $PATH:
    
      1 git … commit --
      hint: Waiting for your editor to close the file...
      Waiting for Emacs...
      *ERROR*: Searching for program: No such file or directory, git
      [...]
    
    A Magit user without git in $PATH must configure the
    magit-git-executable variable, so teach git-commit.el to try to get
    the executable path from the magit-git-executable function.  Using the
    function means that the appropriate path is also used for Tramp
    buffers.
    
    Fixes magit/with-editor#106.
---
 lisp/git-commit.el | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/lisp/git-commit.el b/lisp/git-commit.el
index faca01576f..d4b50f55c7 100644
--- a/lisp/git-commit.el
+++ b/lisp/git-commit.el
@@ -795,6 +795,13 @@ Save current message first."
         (setq str (replace-match "\n" t t str)))
       str)))
 
+;;; Utilities
+
+(defsubst git-commit-executable ()
+  (if (fboundp 'magit-git-executable)
+      (magit-git-executable)
+    "git"))
+
 ;;; Headers
 
 (transient-define-prefix git-commit-insert-pseudo-header ()
@@ -859,13 +866,17 @@ Save current message first."
 (defun git-commit-self-ident ()
   (list (or (getenv "GIT_AUTHOR_NAME")
             (getenv "GIT_COMMITTER_NAME")
-            (ignore-errors (car (process-lines "git" "config" "user.name")))
+            (ignore-errors
+              (car (process-lines
+                    (git-commit-executable) "config" "user.name")))
             user-full-name
             (read-string "Name: "))
         (or (getenv "GIT_AUTHOR_EMAIL")
             (getenv "GIT_COMMITTER_EMAIL")
             (getenv "EMAIL")
-            (ignore-errors (car (process-lines "git" "config" "user.email")))
+            (ignore-errors
+              (car (process-lines
+                    (git-commit-executable) "config" "user.email")))
             (read-string "Email: "))))
 
 (defvar git-commit-read-ident-history nil)
@@ -1037,8 +1048,9 @@ Added to `font-lock-extend-region-functions'."
     (set-syntax-table table))
   (setq-local comment-start
               (or (with-temp-buffer
-                    (call-process "git" nil (current-buffer) nil
-                                  "config" "core.commentchar")
+                    (call-process
+                     (git-commit-executable) nil (current-buffer) nil
+                     "config" "core.commentchar")
                     (unless (bobp)
                       (goto-char (point-min))
                       (buffer-substring (point) (line-end-position))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]