Commit graph

597 commits

Author SHA1 Message Date
Nathan Bellows
b0a8848f68 Add support for @%s time format 2024-02-12 02:05:41 -08:00
Alexandru-Constantin Atomei
3cb6b9d93a Updated CHANGELOG.md, man page and made alias visible in fd -h too 2024-01-01 17:14:32 +02:00
Atomei Alexandru
c591106b86
Merge branch 'master' into dir_alias 2023-12-30 22:58:10 +02:00
Alexandru-Constantin Atomei
9f096737db Added explicit documentation about the possibility of using dir 2023-12-30 22:54:57 +02:00
Alexandru-Constantin Atomei
1bda165b25 Added alias --type dir 2023-12-30 22:14:53 +02:00
Thayne McCombs
9529f30129 fix: Respect NO_COLOR with --list-details option
Fixes: #1455
2023-12-23 21:32:33 +01:00
Tavian Barnes
16c2d1e1d0 walk: Flush stdout in batches
The previous behaviour was designed to mimic the output buffering of
typical UNIX tools: line-buffered if stdout is a TTY, and fully-buffered
otherwise.  More precicely, when printing to a terminal, fd would flush
explicitly after printing any buffered results, then flush after every
single result once streaming mode started.  When not printing to a
terminal, fd never explicitly flushed, so writes would only happen as
the BufWriter filled up.

The new behaviour actually unifies the TTY and non-TTY cases: we flush
after printing the buffered results, then once we start streaming, we
flush after each batch, but *only when the channel is empty*.  This
provides a good balance: if the channel is empty, the receiver thread
might as well flush before it goes to sleep waiting for more results.
If the channel is non-empty, we might as well process those results
before deciding to flush.

For TTYs, this should improve performance by consolidating write() calls
without sacrificing interactivity.  For non-TTYs, we'll be flushing more
often, but only when the receiver would otherwise have nothing to do,
thus improving interactivity without sacrificing performance.  This is
particularly handy when fd is piped into another command (such as head
or grep): with the old behaviour, fd could wait for the whole traversal
to finish before printing anything.  With the new behaviour, fd will
print those results soon after they are received.

Fixes #1313.
2023-12-18 22:01:11 +01:00
Tavian Barnes
fea1622724 cli: Tweak default thread count logic 2023-12-18 21:55:18 +01:00
Tavian Barnes
b8a5f95cf2 walk: Limit batch sizes in --exec mode 2023-11-28 15:51:33 -05:00
Tavian Barnes
73260c0e35 walk: Send WorkerResults in batches 2023-11-28 15:51:33 -05:00
Lena
ad5fb44ddc
fix: display color when NO_COLOR is an empty string 2023-11-04 15:07:10 +01:00
Tavian Barnes
8bbbd7679b walk: New WorkerState struct shared by the worker threads 2023-11-02 17:07:38 +01:00
Thayne McCombs
5ee6365510 Set maximum default threads
Set a limit of how many threads fd will use by default. On hosts that
have a large number of cores, using additional threads has diminishing
returns, and having large numbers of threads increases the setup cost.
Thus we don't necessarily want to use the same number of threads as we
have cores.

Fixes: #1203
2023-10-26 00:48:30 -06:00
Thayne McCombs
1d57b3a064 Simplify parsing number of threads. 2023-10-25 23:56:59 -06:00
Thayne McCombs
325d419e39 Replace num_cpus with std:🧵:available_parallelism
I think this might help startup time a little bit, since it looks like
on linux at least the std implementation uses syscalls to determine the
parallelism, whereas num_cpus was processing the /proc/cpuinfo file.

It also removes another dependency.
2023-10-25 02:00:31 -06:00
João Marcos P. Bezerra
7263b5e01d Fix docs typos 2023-10-24 00:40:12 -03:00
Thayne McCombs
c6fcdbe000 docs: Explicitly warn against relying on result order for exec
Supersedes: #1230
Fixes: #1228
2023-10-23 08:34:15 +02:00
Thayne McCombs
08910e4e3f docs: Some tweaks from review 2023-10-23 08:34:03 +02:00
Thayne McCombs
53fd416c47 docs: Document exclusion of .git/ 2023-10-23 08:34:03 +02:00
Thayne McCombs
054bae01ef maint: Remove use of unmaintained users crate
The users crate is no longer maintained. There is a maintained fork
called uzers, but we already have a dependency on nix, and that has the
functionality we need.
2023-10-21 23:37:32 -06:00
David Peter
0fc8facfb7 Fix --help text 2023-10-21 22:16:15 +02:00
Thayne McCombs
069b181625 Fix documentation for brace escapes 2023-10-21 22:16:15 +02:00
Thayne McCombs
d9b69c8405 feat: Add a way to escape { and }in exec templates.
fixes #1303
2023-10-21 22:16:15 +02:00
Thayne McCombs
a11f8426d4 Fix deprecation warning from chrono
Also change logic to use the latest time if the local time is ambiguous
(for example due to daylight savings)
2023-10-21 14:07:50 +02:00
Christian Göttsche
36bc84041b Support character and block device file types 2023-10-21 13:56:33 +02:00
Thayne McCombs
3ed4ea7538
Merge pull request #1396 from skoriop/default-ignore-git-folder
feat: ignore `.git/` by default
2023-10-20 22:35:22 -06:00
Karthik Prakash
9df9a489f0 refactor: replace map_err with expect
Co-authored-by: Thayne McCombs <astrothayne@gmail.com>
2023-10-18 13:06:51 +05:30
Thayne McCombs
e6b5a4ef9d bug: Update clap to 4.4.6
This also fixes a couple of problems that are now errors:

- Remove use of unstable-grouped feature flag that no longer exists
- Fix some conflicts rules with non-existant options
  * has_results should have been quiet
  * count doesn't exist. I'm not sure where it came from

Fixes: #1397
2023-10-17 23:12:03 -06:00
skoriop
3f9794cd1a feat: ignore .git/ by default 2023-10-15 11:11:53 +05:30
Eden Mikitas
dea9110b90 Making -1 conflict with --exec and making max-results override -1 2023-10-05 15:10:37 +03:00
dependabot[bot]
ed23fb9054 Upgrade regex and regex-syntax
Bump regex from 1.7.3 to 1.9.1

Bumps [regex](https://github.com/rust-lang/regex) from 1.7.3 to 1.8.3.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com

Bump regex-syntax from 0.6.29 to 0.7.2

Bumps [regex-syntax](https://github.com/rust-lang/regex) from 0.6.29 to 0.7.2.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/commits)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: regex-syntax
  dependency-type: direct:production
  update-type: version-update:semver-minor

Supersedes: #1334
Supersedes: #1343
Signed-off-by: dependabot[bot] <support@github.com>
2023-08-09 01:02:55 -06:00
Utkarsh Gupta
3ae04546ea Replace dirs-next crate with etcetera crate 2023-06-14 21:22:28 +02:00
Thayne McCombs
740edeb73f Replace atty with std
std now has a function for testing if stdout is a tty
2023-06-08 00:10:53 -06:00
Thayne McCombs
91e3c3cba5 Replace once_cell with stdlib
LazyLock isn't standardized yet, but OnceLock is good enough for what we
need.
2023-06-08 00:05:00 -06:00
Nathan Houghton
42244e5f32 Don't use jemalloc on OpenBSD (jemalloc fails to compile) 2023-04-14 21:24:19 +02:00
Thayne McCombs
424d6efcc0 fix: Remove unnecessary collection into a vec. 2023-03-20 01:21:00 -06:00
Thayne McCombs
ccf8e69650 fix: clippy warning for unnecessary closure
Now that MSRV is above 1.62, we can use `then_some` instead of a simple
closure.
2023-03-20 01:21:00 -06:00
Thayne McCombs
ee44c1ed90 refactor: Use scoped threads from stdlib in spawn_receiver
This makes it so we don't need to use Arc as much.

Fixes #1141
2023-03-20 01:21:00 -06:00
David Peter
73a693ef28
Merge pull request #1244 from tmccombs/grouped-occurrences
update: Update to clap 4.1
2023-02-01 21:36:19 +01:00
Thayne McCombs
10ba34f78b update: Update to clap 4.1
This includes switching to the stable API for getting values grouped by
occurrences, and updating tests to match the new error messages.
2023-01-17 00:17:50 -07:00
Max 👨🏽‍💻 Coplan
08c0d427bf Add flag --no-require-git to always respect gitignore files
Summary: Currently, `--ignore-vcs` only serves to unset `--no-ignore-vcs`.
There is currently no way to tell fd to respect gitignore files when not in a
git repository.  This commit adds the flag `--no-require-git` to make fd always
respect all gitignore files.

This behaves the same as the `--no-require-git` option in [ripgrep](3bb71b0cb8/crates/core/app.rs (L2214-L2226))

This commit also contains an unrelated wording fix to CONTRIBUTING.md

Test Plan: `tests/tests.rs`

Background: I am using [Sapling](https://sapling-scm.com/docs/introduction/)
for working with git repositories (including this commit ☺️).  Since Sapling
uses `.sl` instead of `.git`, tools using the `ignore` crate (rg and fd) would show gitignored files.
I made a patch (ebf17eef22)
to `ignore` to respect gitignores with _either_ `.git` or `.sl`.  However,
@BurntSushi said he did not want to merge that patch and instead suggested I
use `--no-require-git` (https://github.com/BurntSushi/ripgrep/issues/2374).
This works fine, but I couldn't use this workaround for my other favorite tool!
That's what this patch is for 😁

(a follow-up patch will add a similar `FD_CONFIG_PATH` environment variable
like `RG_CONFIG_PATH`)
2023-01-13 13:52:34 -08:00
Thayne McCombs
27013537c9 Fix logic for when to read global ignore file
Fixes #1209
2022-12-17 00:28:47 -07:00
Thayne McCombs
b7a2f68d59 Mention --changed-after alias in long help 2022-12-06 01:28:15 -07:00
Thayne McCombs
e98a6c6755 Use docstrings for long help in clap derive 2022-12-06 01:28:15 -07:00
Thayne McCombs
39d80a59b6 Remove time from transitive dependencies of chrono
Because chrono was depending on an older version of time, and we don't
actually need it with recent versions of chrono.

Relates-To: #1188
Alernative-To: #1190
2022-12-03 01:28:17 -07:00
Thayne McCombs
d441516c9d Use nu-ansi-term instead of ansi-term
Because ansi-term is no longer maintained.

Relates-To: #1188
2022-12-01 00:07:30 -07:00
David Peter
36e60223eb Use allow_hyphen_values = true for --and <pattern> 2022-11-21 21:08:41 +01:00
David Peter
0d9926de40 Move --and option up to other patter-related options 2022-11-21 21:06:48 +01:00
David Peter
e147ba901b Minor fixes in help text 2022-11-21 21:06:48 +01:00
Kasper Gałkowski
7e26925933 Added the --and flag for matching multiple patterns 2022-11-21 21:06:48 +01:00