unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Sean Allred <allred.sean@gmail.com>,
	Michael Albinus <michael.albinus@gmx.de>
Cc: 73320@debbugs.gnu.org
Subject: bug#73320: [PATCH] project--vc-list-files: use Git's sparse-index
Date: Fri, 4 Oct 2024 02:57:22 +0300	[thread overview]
Message-ID: <8e00a62b-c531-4593-90c3-55e060c5434f@gutov.dev> (raw)
In-Reply-To: <m04j6cnuay.fsf@epic96565.epic.com>

[-- Attachment #1: Type: text/plain, Size: 967 bytes --]

On 19/09/2024 07:25, Sean Allred wrote:
> awkward state between Git
> 2.25 (where sparse-checkout was introduced) and 2.35 (where git-ls-files
> learned --sparse)

Speaking of versions, I've triggered an error on a remote host (with 
Tramp) because it had older Git installed.

It was running a Trisquel 9.0, which is pretty old, but looking at 
https://repology.org/project/git/versions it appears even the latest 
Trisquel (11.0) only uses Git 2.34. Same for Ubuntu 22.04 which it's 
based on, both officially supported until 2027.

The attached makes detected version connection-local, that's step 1 (*).

It could use some review, though. There aren't many examples of doing 
that in Emacs code.

Michael, could you take a look? Does this look reasonable? Should 
:application be 'tramp' or 'vc-git'? Is the 
'connection-local-set-profiles' call needed here at all or can be skipped?

(*) Step 2 might be to limit the --sparse argument to Emacs 31 and 
newer. :-/

[-- Attachment #2: vc-git--program-version-connection-local.diff --]
[-- Type: text/x-patch, Size: 2141 bytes --]

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 05400523048..2a40539adeb 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -315,21 +315,31 @@ 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
-              (if (and version-string
-                       ;; Some Git versions append additional strings
-                       ;; to the numerical version string. E.g., Git
-                       ;; for Windows appends ".windows.N", while Git
-                       ;; for Mac appends " (Apple Git-N)". Capture
-                       ;; numerical version and ignore the rest.
-                       (string-match "git version \\([0-9][0-9.]+\\)"
-                                     version-string))
-                  (string-trim-right (match-string 1 version-string) "\\.")
-                "0")))))
+  (with-connection-local-variables
+   (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
+                   ;; for Windows appends ".windows.N", while Git
+                   ;; for Mac appends " (Apple Git-N)". Capture
+                   ;; numerical version and ignore the rest.
+                   (string-match "git version \\([0-9][0-9.]+\\)"
+                                 version-string))
+              (string-trim-right (match-string 1 version-string) "\\.")
+            "0"))))))
 
 (defun vc-git--git-path (&optional path)
   "Resolve .git/PATH for the current working tree.

  parent reply	other threads:[~2024-10-03 23:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-17 16:55 bug#73320: [PATCH] project--vc-list-files: use Git's sparse-index Sean Allred
2024-09-17 22:54 ` Dmitry Gutov
2024-09-18  0:36   ` Sean Allred
2024-09-18 22:27     ` Dmitry Gutov
2024-09-19  4:25       ` Sean Allred
2024-09-19  9:44         ` Dmitry Gutov
2024-09-29  1:19           ` Dmitry Gutov
2024-10-03 23:57         ` Dmitry Gutov [this message]
2024-10-04  7:48           ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-04 21:25             ` Dmitry Gutov
2024-10-05  6:48               ` Eli Zaretskii
2024-10-05 12:33                 ` Dmitry Gutov
2024-10-07 23:55                   ` Dmitry Gutov
2024-10-07  0:41               ` Jim Porter
2024-10-07 23:38                 ` Dmitry Gutov
2024-09-19  5:41       ` Eli Zaretskii
2024-09-19  9:34         ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e00a62b-c531-4593-90c3-55e060c5434f@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=73320@debbugs.gnu.org \
    --cc=allred.sean@gmail.com \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).