Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1148] Don't show deleted files in listing #1825

Merged
merged 6 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* Add elm project type.
* [#1821](https://github.com/bbatsov/projectile/pull/1821): Add `pyproject.toml` discovery for python projects.

### Changes

* [#1285](https://github.com/bbatsov/projectile/pull/1825): By default, use [fd](https://github.com/sharkdp/fd) in Git repositories instead of `git ls-files` when it is installed, in order to solve the problem where deleted files were still shown in `projectile-find-file` until their deletions were staged. The user-facing behavior should be the same, although potentially with different performance characteristics in large Git repositories. The old behavior can be reclaimed by setting `projectile-git-use-fd` to nil.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also make a note of this in the docs (probably somewhere in usage and in the FAQ).

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized there is a separate usage page apart from the readme. It already says fd is used when possible and installed, shall I add more detail about how Projectile determines which tool to use?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess that'd be a nice addition to the docs.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


## 2.7.0 (2022-11-22)

### New features
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ To get the most of Projectile you also need to enable (and potentially install)
* Using Projectile over TRAMP might be slow in certain cases.
* Some commands might misbehave on complex project setups (e.g. a git project with submodules).
* Projectile was mostly tested on Unix OS-es (e.g. GNU/Linux and macOS), so some functionality might not work well on Windows.
* In Git repositories, deleted files are still shown in `projectile-find-file` until their deletions are staged, due to a limitation of `git ls-files`. If you install [fd](https://github.com/sharkdp/fd) then it is automatically used instead, and does not have this problem. (You can inhibit the use of `fd` by setting `projectile-git-use-fd` to nil.)

## Known issues

Expand Down
21 changes: 21 additions & 0 deletions doc/modules/ROOT/pages/faq.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ super convenient for many people.
Eventually this was changed in Projectile 2.0. That's why currently Projectile
requires users to select a prefix key for its commands explicitly.

== What dependencies does Projectile have?

Projectile will work without any external dependencies out of the box.
However, if you have various tools installed, they will be
automatically used when appropriate to improve performance.

Inside version control repositories, VC tools are used when installed
to list files more efficiently. The supported tools include git, hg,
fossil, bzr, darcs, pijul, and svn.

Outside version control repositories, file search tools are used when
installed for a faster search than pure Elisp. The supported tools
include https://github.com/sharkdp/fd[fd] and GNU/BSD find.

By default, if fd is installed, it is also used inside Git
repositories as an alternative to `git ls-files`, because `git
ls-files` has the limitation that it also lists deleted files until
the deletions are staged, which can be confusing. You can eliminate
the use of fd in this circumstance by setting `projectile-git-use-fd`
to nil.

== Do you need some help cleanup up all those tickets that have piled up?

Certainly! In our https://github.com/bbatsov/projectile/issues/[issue
Expand Down
29 changes: 23 additions & 6 deletions doc/modules/ROOT/pages/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,29 @@ a good idea to enable `prescient` (a package similar to `flx`).

NOTE: Windows users can ignore this section unless they are using Emacs via WSL or `cygwin`.

It's recommended to install the following command-line tools:

* `fd` (a super-fast alternative to `find`)
* `ag` (a.k.a. `the_silver_searcher`, a powerful alternative to `grep`) or `rg` (a.k.a. `ripgrep`)

Projectile will make use of them automatically when available, and fallback to the standard Unix tools otherwise.
Projectile will work without any external dependencies out of the box.
However, if you have various tools installed, they will be
automatically used when appropriate to improve performance.

Inside version control repositories, VC tools are used when installed
to list files more efficiently. The supported tools include git, hg,
fossil, bzr, darcs, pijul, and svn.

Outside version control repositories, file search tools are used when
installed for a faster search than pure Elisp. The supported tools
include https://github.com/sharkdp/fd[fd] and GNU/BSD find.

By default, if fd is installed, it is also used inside Git
repositories as an alternative to `git ls-files`, because `git
ls-files` has the limitation that it also lists deleted files until
the deletions are staged, which can be confusing. You can eliminate
the use of fd in this circumstance by setting `projectile-git-use-fd`
to nil.

To benefit from the `projectile-ag` and `projectile-ripgrep` commands
to perform file search, it's recommended to install
https://github.com/ggreer/the_silver_searcher[ag] (`the_silver_searcher`) and/or
https://github.com/BurntSushi/ripgrep[rg] (`ripgrep`)

TIP: You should also install the Emacs packages `ag`, `ripgrep` or `rg` if you want to make sure of Projectile's commands `projectile-ag` and `projectile-ripgrep`.

Expand Down
32 changes: 31 additions & 1 deletion projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,36 @@ means check all the subdirectories of DIRECTORY. Etc."
:type '(repeat (choice directory (cons directory (integer :tag "Depth"))))
:package-version '(projectile . "1.0.0"))

(defcustom projectile-fd-executable
(cond
((executable-find "fdfind") "fdfind")
((executable-find "fd") "fd"))
"Path or name of fd executable used by Projectile if enabled.
Nil means fd is not installed or should not be used."
:type 'string)
raxod502 marked this conversation as resolved.
Show resolved Hide resolved

(defcustom projectile-git-use-fd (when projectile-fd-executable t)
"Non-nil means use fd to implement git ls-files.
This may change Projectile's performance in large Git repositories
depending on your system, but it will also work around the Git behavior
that causes deleted files to still be shown in Projectile listings until
their deletions are staged."
:type 'boolean
:package-version '(projectile . "2.8.0"))

(defcustom projectile-git-command "git ls-files -zco --exclude-standard"
"Command used by projectile to get the files in a git project."
:group 'projectile
:type 'string)

(defcustom projectile-git-fd-args "-H -0 -E .git -tf --strip-cwd-prefix"
"Arguments to fd used to re-implement `git ls-files'.
This is used with `projectile-fd-executable' when `projectile-git-use-fd'
is non-nil."
:group 'projectile
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should have a :package-version as well.

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, b68f7ef

:type 'string
:package-version '(projectile . "2.8.0"))

(defcustom projectile-git-submodule-command "git submodule --quiet foreach 'echo $displaypath' | tr '\\n' '\\0'"
"Command used by projectile to list submodules of a given git repository.
Set to nil to disable listing submodules contents."
Expand Down Expand Up @@ -1422,7 +1447,12 @@ IGNORED-DIRECTORIES may optionally be provided."
"Determine which external command to invoke based on the project's VCS.
Fallback to a generic command when not in a VCS-controlled project."
(pcase vcs
('git projectile-git-command)
('git (if (and projectile-git-use-fd projectile-fd-executable)
(concat
projectile-fd-executable
" "
projectile-git-fd-args)
projectile-git-command))
('hg projectile-hg-command)
('fossil projectile-fossil-command)
('bzr projectile-bzr-command)
Expand Down