From: Dmitry Gutov <dmitry@gutov.dev>
To: Sean Allred <allred.sean@gmail.com>
Cc: 73320@debbugs.gnu.org
Subject: bug#73320: [PATCH] project--vc-list-files: use Git's sparse-index
Date: Thu, 19 Sep 2024 01:27:03 +0300 [thread overview]
Message-ID: <73758f39-1e18-471a-9dfb-0ceade12dacf@gutov.dev> (raw)
In-Reply-To: <m0cyl1ol0n.fsf@epic96565.epic.com>
On 18/09/2024 03:36, Sean Allred wrote:
> Dmitry Gutov <dmitry@gutov.dev> writes:
>> The submitted patch has a comma inside which results in an error
>
> Well that's embarrassing. I've resolved this in my branch. I'm not sure
> why I wasn't seeing an issue locally; perhaps I made this error somehow
> after I eval'd the form for testing. Thanks for catching!
No problem!
>> But let's start from the beginning. Could you help me set up a sparse
>> repo that would help test out the change?
>>
>> I took a large-ish checkout with shallow history and set up the sparse
>> config like this:
>>
>> git sparse-checkout init --cone
>> git sparse-checkout set gfx media
>>
>> With that, both 'git status' and 'ls' behave as expected - no extra
>> directories around (just the top-level files and two subdirs).
>>
>> But 'git ls-files' and 'git ls-files --sparse' continue to show the
>> same large output. Any idea what could be wrong? My version of Git,
>> perhaps? Which is 2.40.1.
>
> Sure! You're very close. The key is here in git-ls-files(1):
>
> --sparse
> If the index is sparse, show the sparse directories without
> expanding to the contained files. Sparse directories will be shown
> with a trailing slash, such as "x/" for a sparse directory "x".
>
> combined with this in git-sparse-checkout(1):
>
> Use the --[no-]sparse-index option to use a sparse index (the
> default is to not use it).
>
> I fell into this too when setting up my worktree for testing; normally
> our internal tooling takes care of this for me. To resolve this issue in
> an existing checkout, you can simply
>
> git sparse-checkout init --sparse-index
>
> and that will rewrite your index file using sparse-index rules.
Thanks! So the key here is using "sparse index", not just "sparse
checkout", since these are two different features. Which have to be
enabled separately for sort of "gradual rollout", I guess.
>> Yeah, I expect project-find-regexp, project-search,
>> project-query-replace-regexp might start misbehaving without
>> additional filtering -- either throwing up errors or, best case,
>> continuing to search through the "hidden" directories.
>
> Not sure how best to track that we should come back to this, but yeah.
> It seems like the right place to add some sort of switch would be in the
> `project-files` defmethod. From here, it looks like all the functions
> you mention could choose the behavior right for them. (Based on the
> function names alone -- it seems they would /also/ be interested in
> operating on only those files which exist on disk.)
I think we can just remove the names ending with '/'. The built-in
commands don't seem to error out on them right now - probably because
there is some protection against nonexistent files - but those files are
(were) still shown as completions for project-find-file. Try out this
addition please. The performance here seems about the same even with a
large list (something I was worried about):
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index b29d5ed5404..a2e3f3f52e6 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -663,7 +663,7 @@ project--vc-list-files
(pcase backend
(`Git
(let* ((default-directory (expand-file-name
(file-name-as-directory dir)))
- (args '("-z"))
+ (args '("-z" "--sparse"))
(vc-git-use-literal-pathspecs nil)
(include-untracked (project--value-in-dir
'project-vc-include-untracked
@@ -703,7 +703,8 @@ project--vc-list-files
(delq nil
(mapcar
(lambda (file)
- (unless (member file submodules)
+ (unless (or (member file submodules)
+ (eq ?/ (aref file (1- (length file)))))
(if project-files-relative-names
file
(concat default-directory file))))
> Incidentally looking at the version check within `project-files`, it's
> worthwhile to point out that `--sparse` is likely /not/ compatible with
> ancient versions of Git. Does vc have any sort of policy on requiring
> recent versions of these tools? If the answer is 'not really', I'll
> additionally want to add some sort of protection against using
> `--sparse` when the Git version won't understand it. This should be easy
> enough to do within the implementation of `project--vc-list-files`.
IIRC it was something like "should work on the CentOS stable", and maybe
CentOS N-1 as well. But the release-based distro was discontinued since
the last time this question came up ;-(
We can call vc-git--program-version the same way it's used in
vc-git-state. Which version should we make the minimum?
next prev parent reply other threads:[~2024-09-18 22:27 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 [this message]
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
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=73758f39-1e18-471a-9dfb-0ceade12dacf@gutov.dev \
--to=dmitry@gutov.dev \
--cc=73320@debbugs.gnu.org \
--cc=allred.sean@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.