emacs-31 a9fc13614ec: Export GIT_OPTIONAL_LOCKS=0 for "git status" invocations (bug#80903)
Sean Whitton <[email protected]> Fri, 31 Jul 2026 11:20:44 -0400 (EDT)
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: emacs-31 commit a9fc13614eca8aaa34d227b28c4c4d37b13212af Author: Sean Whitton <[email protected]> Commit: Sean Whitton <[email protected]> Export GIT_OPTIONAL_LOCKS=0 for "git status" invocations (bug#80903) * lisp/vc/vc-git.el (vc-git--env-vars): New function. (vc-git-command, vc-git--call): Use it (bug#80903). --- lisp/vc/vc-git.el | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index f336aae984d..17c358e25d5 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -2884,6 +2884,21 @@ page for the meanings of these attributes." ;;; Internal commands +(defun vc-git--env-vars (subcommand) + "Return env vars for the `process-environment' of Git processes." + `("GIT_DIR" + ,@(and vc-git-use-literal-pathspecs + '("GIT_LITERAL_PATHSPECS=1")) + ;; Avoid optional repository locking during background operations + ;; (bug#21559, bug#80903). Skipping these locks is always safe and + ;; can only lead to subsequent commands running more slowly. + ;; The "git status" case covers how `vc-checkin' uses + ;; `vc-dir-resynch-file' to update the display state of files + ;; undergoing an asynchronous check-in. + ,@(and (or revert-buffer-in-progress + (equal subcommand "status")) + '("GIT_OPTIONAL_LOCKS=0")))) + (defun vc-git-command (buffer okstatus file-or-list &rest flags) "A wrapper around `vc-do-command' for use in vc-git.el. The difference to `vc-do-command' is that this function always invokes @@ -2903,16 +2918,8 @@ The difference to `vc-do-command' is that this function always invokes ;; want to do it only for commands which really require it. (coding-system-for-write (or coding-system-for-write vc-git-commits-coding-system)) - (process-environment - (append - `("GIT_DIR" - ,@(and vc-git-use-literal-pathspecs - '("GIT_LITERAL_PATHSPECS=1")) - ;; Avoid repository locking during background operations - ;; (bug#21559). - ,@(and revert-buffer-in-progress - '("GIT_OPTIONAL_LOCKS=0"))) - process-environment)) + (process-environment (append (vc-git--env-vars (car flags)) + process-environment)) (file1 (and (not (cdr-safe file-or-list)) (or (car-safe file-or-list) file-or-list))) (file-list-is-rootdir (and file1 @@ -2954,16 +2961,8 @@ The difference to `vc-do-command' is that this function always invokes (or coding-system-for-read vc-git-log-output-coding-system)) (coding-system-for-write (or coding-system-for-write vc-git-commits-coding-system)) - (process-environment - (append - `("GIT_DIR" - ,@(when vc-git-use-literal-pathspecs - '("GIT_LITERAL_PATHSPECS=1")) - ;; Avoid repository locking during background operations - ;; (bug#21559). - ,@(when revert-buffer-in-progress - '("GIT_OPTIONAL_LOCKS=0"))) - process-environment))) + (process-environment (append (vc-git--env-vars command) + process-environment))) (apply #'process-file vc-git-program infile buffer nil "--no-pager" command args)))