GNU bug report logs -
#73320
[PATCH] project--vc-list-files: use Git's sparse-index
Previous Next
Reported by: Sean Allred <allred.sean <at> gmail.com>
Date: Tue, 17 Sep 2024 16:57:02 UTC
Severity: normal
Tags: patch
Done: Dmitry Gutov <dmitry <at> gutov.dev>
Bug is archived. No further changes may be made.
Full log
Message #40 received at 73320 <at> debbugs.gnu.org (full text, mbox):
Hi Michael, Eli,
On 04/10/2024 10:48, Michael Albinus wrote:
>> It could use some review, though. There aren't many examples of doing
>> that in Emacs code.
> In Eshell, Jim Porter makes extensive use of connection-local
> variables. He has also added some functions which are useful (not
> applied in Tramp yet).
Yep, Eshell seems to be have been the only other client of
connection-local, until now. I was wondering whether setting a unique
application name is the recommended pattern, though.
> However, you use with-connection-local-variables, which uses the
> application `tramp' by default. Either use
> with-connection-local-application-variables instead, or let-bind
> connection-local-default-application to `vc-git'.
>
> I'm not sure how setq-connection-local behaves wrt to the application
> (this function was written by Jim, I've never used it). But binding
> connection-local-default-application should be good enough, I believe.
>
>> Is the 'connection-local-set-profiles' call needed here at all or can
>> be skipped?
> It is needed. connection-local-set-profile-variables declares only the
> variables, connection-local-set-profiles activates them.
Thanks, Michael. Binding connection-local-default-application seems like
a good approach for Emacs 27-28, but vc-git is not distributed
separately, so might as well use the newer macro.
Here's the updated patch.
Eli, any chance this can go in Emacs 30? Could be considered a bugfix,
since we're fixing Git version detection on remote hosts. Not a
regression, though.
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 05400523048..5a7ffeffc9d 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -315,11 +315,21 @@ vc-git--state-code
(defvar vc-git--program-version nil)
+(connection-local-set-profile-variables
+ 'vc-git-connection-default-profile
+ '((vc-git--program-version . nil)))
+
+(connection-local-set-profiles
+ '(:application vc-git)
+ 'vc-git-connection-default-profile)
+
(defun vc-git--program-version ()
- (or vc-git--program-version
- (let ((version-string
- (vc-git--run-command-string nil "version")))
- (setq vc-git--program-version
+ (with-connection-local-application-variables 'vc-git
+ (or vc-git--program-version
+ (let ((version-string
+ (vc-git--run-command-string nil "version")))
+ (setq-connection-local
+ vc-git--program-version
(if (and version-string
;; Some Git versions append additional strings
;; to the numerical version string. E.g., Git
@@ -329,7 +339,7 @@ vc-git--program-version
(string-match "git version \\([0-9][0-9.]+\\)"
version-string))
(string-trim-right (match-string 1 version-string)
"\\.")
- "0")))))
+ "0"))))))
(defun vc-git--git-path (&optional path)
"Resolve .git/PATH for the current working tree.
This bug report was last modified 226 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.