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

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

[nongnu] elpa/git-commit bd24afc012 2/4: git-commit-setup-font-lock: Tig


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit bd24afc012 2/4: git-commit-setup-font-lock: Tighten git-config output processing
Date: Mon, 21 Feb 2022 01:58:05 -0500 (EST)

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

    git-commit-setup-font-lock: Tighten git-config output processing
    
    git-commit-setup-font-lock calls 'git config core.commentchar' via
    call-process.  This call exits with 1 if the key isn't found.  On
    success or failure, that normally shouldn't produce any stderr, and on
    success the only stdout should be the core.commentchar.
    
    But to be safe and reduce the chances of processing unintended output,
    1) stop if there was a non-zero exit and 2) insert only standard
    output into the buffer.
---
 lisp/git-commit.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/git-commit.el b/lisp/git-commit.el
index d4b50f55c7..370db36ea7 100644
--- a/lisp/git-commit.el
+++ b/lisp/git-commit.el
@@ -1048,12 +1048,14 @@ Added to `font-lock-extend-region-functions'."
     (set-syntax-table table))
   (setq-local comment-start
               (or (with-temp-buffer
-                    (call-process
-                     (git-commit-executable) nil (current-buffer) nil
-                     "config" "core.commentchar")
-                    (unless (bobp)
-                      (goto-char (point-min))
-                      (buffer-substring (point) (line-end-position))))
+                    (and (zerop
+                          (call-process
+                           (git-commit-executable) nil (list t nil) nil
+                           "config" "core.commentchar"))
+                         (not (bobp))
+                         (progn
+                           (goto-char (point-min))
+                           (buffer-substring (point) (line-end-position)))))
                   "#"))
   (setq-local comment-start-skip (format "^%s+[\s\t]*" comment-start))
   (setq-local comment-end-skip "\n")



reply via email to

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