Compare commits

...

23 Commits

Author SHA1 Message Date
Thayne McCombs 447edc7604
Merge 11e328cecd into cd96ca071d 2024-05-05 06:50:42 +00:00
Thayne McCombs 11e328cecd feat: Add option to always include cwd prefix
Fixes: #1243
Fixes: #1331
2024-05-05 00:50:35 -06:00
Thayne McCombs cd96ca071d
Merge pull request #1547 from tavianator/jemalloc-aarch64
ci: Support large page sizes on AArch64
2024-05-03 21:46:40 -06:00
Tavian Barnes 216472ff9f ci: Support large page sizes on AArch64
Fixes #1085.
2024-05-03 15:23:41 -04:00
Thayne McCombs 3680d10e5c
Merge pull request #1544 from sharkdp/dependabot/cargo/libc-0.2.154
build(deps): bump libc from 0.2.153 to 0.2.154
2024-05-01 12:03:31 -06:00
dependabot[bot] abe3b9cd78
build(deps): bump libc from 0.2.153 to 0.2.154
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.153 to 0.2.154.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.153...0.2.154)

---
updated-dependencies:
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 17:47:51 +00:00
Thayne McCombs 7aad6c9edf
Merge pull request #1543 from sharkdp/dependabot/cargo/chrono-0.4.38
build(deps): bump chrono from 0.4.37 to 0.4.38
2024-05-01 11:47:39 -06:00
Thayne McCombs ddd3aae249
Merge pull request #1542 from sharkdp/dependabot/cargo/nix-0.28.0
build(deps): bump nix from 0.27.1 to 0.28.0
2024-05-01 11:46:53 -06:00
dependabot[bot] 6d3bb68faf
build(deps): bump chrono from 0.4.37 to 0.4.38
Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.37 to 0.4.38.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.37...v0.4.38)

---
updated-dependencies:
- dependency-name: chrono
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 17:31:34 +00:00
dependabot[bot] 21d50dae8c
build(deps): bump nix from 0.27.1 to 0.28.0
Bumps [nix](https://github.com/nix-rust/nix) from 0.27.1 to 0.28.0.
- [Changelog](https://github.com/nix-rust/nix/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nix-rust/nix/compare/v0.27.1...v0.28.0)

---
updated-dependencies:
- dependency-name: nix
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 17:31:29 +00:00
David Peter 9279b1f0af Fix typo in CHANGELOG 2024-04-30 15:56:12 +02:00
Thayne McCombs 6647085015 Add test for gitignore workaround
And make sure it works for user-supplied path of "."

Also add changelog entry
2024-04-30 15:56:12 +02:00
Thayne McCombs 6af8f092ee Workaround for bug with gitinored files
This is a workaround for
https://github.com/BurntSushi/ripgrep/issues/2711

Fixes: #1461
2024-04-30 15:56:12 +02:00
Thayne McCombs c4094c7a05
Merge pull request #1492 from AlbydST/master
Add installation instructions for more Linux distributions in README
2024-04-29 13:13:38 -06:00
AlbydS 6d58df5f0c
Remove unnecessary sudo in front of commands
Removed unnecessary "sudo" in front of all commands, also removed the "replace sudo with doas..." instruction at the end.
2024-04-29 18:04:39 +00:00
AlbydS ffecccf209
Merge branch 'sharkdp:master' into master 2024-04-29 17:58:24 +00:00
Thayne McCombs 31f2839751
Merge pull request #1540 from tmccombs/revert-git-ignore
Stop ignore .git folders by default
2024-04-28 20:33:03 -06:00
Thayne McCombs e10a4eab2b Stop ignore .git folders by default
Fixes: #1457
See: #1396, #1403
2024-04-28 20:23:25 -06:00
Thayne McCombs 8eb047945e
Merge pull request #1541 from tavianator/clippy-is-empty
filesystem: Remove a redundant as_str()
2024-04-28 20:22:10 -06:00
Tavian Barnes 1031325cca filesystem: Remove a redundant as_str() 2024-04-28 17:30:44 -04:00
Tavian Barnes 9fc2167cf9
Merge pull request #1505 from leuven65/master
set default path separator to '/' in UCRT64 of MSYS
2024-04-28 17:23:43 -04:00
Jian Wang f875ea9a52 Set default path separator to '/' in MSYS/MSYS2
The environments of MSYS: [[https://www.msys2.org/docs/environments/]]
2024-03-13 19:32:13 +01:00
AlbydS d651a595d4
Add installation instructions for more Linux distributions in README
Added installation instructions for Arch AUR, ALT Linux and Solus and did a few minor changes
2024-02-11 21:25:33 +01:00
12 changed files with 136 additions and 52 deletions

View File

@ -134,7 +134,11 @@ jobs:
- name: Build
shell: bash
run: $BUILD_CMD build --locked --release --target=${{ matrix.job.target }}
run: |
case ${{ matrix.job.target }} in
aarch64-*) export JEMALLOC_SYS_WITH_LG_PAGE=16 ;;
esac;
$BUILD_CMD build --locked --release --target=${{ matrix.job.target }}
- name: Set binary name & path
id: bin

View File

@ -4,10 +4,17 @@
- Add `dir` as an alias to `directory` when using `-t` \ `--type`, see #1460 and #1464 (@Ato2207).
- Add support for @%s date format in time filters similar to GNU date (seconds since Unix epoch for --older/--newer), see #1493 (@nabellows)
- Breaking: No longer automatically ignore `.git` when using `--hidden` with vcs ignore enabled. This reverts the change in v9.0.0. While this feature
was often useful, it also broke some existing workflows, and there wasn't a good way to opt out of it. And there isn't really a good way for us to add
a way to opt out of it. And you can easily get similar behavior by adding `.git/` to your global fdignore file.
See #1457.
- Allow passing an optional argument to `--strip-cwd-prefix` of "always", "never", or "auto". to force whether the cwd prefix is stripped or not.
## Bugfixes
- Respect NO_COLOR environment variable with `--list-details` option. (#1455)
- Fix bug that would cause hidden files to be included despite gitignore rules
if search path is "." (#1461, BurntSushi/ripgrep#2711).
## Changes

21
Cargo.lock generated
View File

@ -145,9 +145,9 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "chrono"
version = "0.4.37"
version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e"
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
dependencies = [
"android-tzdata",
"iana-time-zone",
@ -327,7 +327,7 @@ dependencies = [
"jemallocator",
"libc",
"lscolors",
"nix 0.27.1",
"nix 0.28.0",
"normpath",
"nu-ansi-term",
"regex",
@ -459,9 +459,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.153"
version = "0.2.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]]
name = "linux-raw-sys"
@ -501,17 +501,6 @@ dependencies = [
"libc",
]
[[package]]
name = "nix"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
"bitflags 2.5.0",
"cfg-if",
"libc",
]
[[package]]
name = "nix"
version = "0.28.0"

View File

@ -55,7 +55,7 @@ version = "4.4.13"
features = ["suggestions", "color", "wrap_help", "cargo", "derive"]
[dependencies.chrono]
version = "0.4.34"
version = "0.4.38"
default-features = false
features = ["std", "clock"]
@ -65,7 +65,7 @@ default-features = false
features = ["nu-ansi-term"]
[target.'cfg(unix)'.dependencies]
nix = { version = "0.27.1", default-features = false, features = ["signal", "user"] }
nix = { version = "0.28.0", default-features = false, features = ["signal", "user"] }
[target.'cfg(all(unix, not(target_os = "redox")))'.dependencies]
libc = "0.2"

View File

@ -282,6 +282,9 @@ If you want `fd` to ignore these patterns globally, you can put them in `fd`'s g
This is usually located in `~/.config/fd/ignore` in macOS or Linux, and `%APPDATA%\fd\ignore` in
Windows.
You may wish to include `.git/` in your `fd/ignore` file so that `.git` directories, and their contents
are not included in output if you use the `--hidden` option.
### Deleting files
You can use `fd` to remove all files and directories that are matched by your search pattern.
@ -533,7 +536,7 @@ newlines). In the same way, the `-0` option of `xargs` tells it to read the inpu
If you run Ubuntu 19.04 (Disco Dingo) or newer, you can install the
[officially maintained package](https://packages.ubuntu.com/fd-find):
```
sudo apt install fd-find
apt install fd-find
```
Note that the binary is called `fdfind` as the binary name `fd` is already used by another package.
It is recommended that after installation, you add a link to `fd` by executing command
@ -543,7 +546,7 @@ Make sure that `$HOME/.local/bin` is in your `$PATH`.
If you use an older version of Ubuntu, you can download the latest `.deb` package from the
[release page](https://github.com/sharkdp/fd/releases) and install it via:
``` bash
sudo dpkg -i fd_9.0.0_amd64.deb # adapt version number and architecture
dpkg -i fd_9.0.0_amd64.deb # adapt version number and architecture
```
### On Debian
@ -551,7 +554,7 @@ sudo dpkg -i fd_9.0.0_amd64.deb # adapt version number and architecture
If you run Debian Buster or newer, you can install the
[officially maintained Debian package](https://tracker.debian.org/pkg/rust-fd-find):
```
sudo apt-get install fd-find
apt-get install fd-find
```
Note that the binary is called `fdfind` as the binary name `fd` is already used by another package.
It is recommended that after installation, you add a link to `fd` by executing command
@ -579,6 +582,8 @@ You can install [the fd package](https://www.archlinux.org/packages/community/x8
```
pacman -S fd
```
You can also install fd [from the AUR](https://aur.archlinux.org/packages/fd-git).
### On Gentoo Linux
You can use [the fd ebuild](https://packages.gentoo.org/packages/sys-apps/fd) from the official repo:
@ -600,6 +605,20 @@ You can install `fd` via xbps-install:
xbps-install -S fd
```
### On ALT Linux
You can install [the fd package](https://packages.altlinux.org/en/sisyphus/srpms/fd/) from the official repo:
```
apt-get install fd
```
### On Solus
You can install [the fd package](https://github.com/getsolus/packages/tree/main/packages/f/fd) from the official repo:
```
eopkg install fd
```
### On RedHat Enterprise Linux 8/9 (RHEL8/9), Almalinux 8/9, EuroLinux 8/9 or Rocky Linux 8/9
You can install [the `fd` package](https://copr.fedorainfracloud.org/coprs/tkbcopr/fd/) from Fedora Copr.
@ -620,7 +639,7 @@ brew install fd
… or with MacPorts:
```
sudo port install fd
port install fd
```
### On Windows
@ -665,7 +684,7 @@ pkg install fd-find
### From npm
On linux and macOS, you can install the [fd-find](https://npm.im/fd-find) package:
On Linux and macOS, you can install the [fd-find](https://npm.im/fd-find) package:
```
npm install -g fd-find

View File

@ -162,7 +162,7 @@ _fd() {
$no'(*)*--search-path=[set search path (instead of positional <path> arguments)]:directory:_files -/'
+ strip-cwd-prefix
$no'(strip-cwd-prefix exec-cmds)--strip-cwd-prefix[Strip ./ prefix when output is redirected]'
$no'(strip-cwd-prefix exec-cmds)--strip-cwd-prefix=[When to strip ./]:when:(always never auto)'
+ and
'--and=[additional required search path]:pattern'

45
doc/fd.1 vendored
View File

@ -33,16 +33,14 @@ with the '\-\-glob' option.
By default
.B fd
will exclude hidden files and directories, as well as any files that match gitignore rules
or ignore rules in .ignore or .fdignore files. For convenenience, '.git' is treated as if it
was always included in gitignore rules. These files can be included with options such as
'\-\-hidden' and '\-\-no\-ignore'.
or ignore rules in .ignore or .fdignore files.
.SH OPTIONS
.TP
.B \-H, \-\-hidden
Include hidden files and directories in the search results
(default: hidden files and directories are skipped). The flag can be overridden with '--no-hidden'.
.IP
Ignored files and .git/ are still excluded unless \-\-no\-ignore or \-\-no\-ignore\-vcs
Ignored files are still excluded unless \-\-no\-ignore or \-\-no\-ignore\-vcs
is also used.
.TP
.B \-I, \-\-no\-ignore
@ -79,7 +77,6 @@ and the global gitignore configuration
.RI ( core.excludesFile
git setting, which defaults to
.IR $HOME/.config/git/ignore ).
The pattern ".git/" is automatically added to the list of VCS ignore rules.
The flag can be overridden with '--ignore-vcs'.
.TP
.B \-\-no\-require\-git
@ -159,9 +156,20 @@ can be used as an alias.
Enable the display of filesystem errors for situations such as insufficient
permissions or dead symlinks.
.TP
.B \-\-strip-cwd-prefix
By default, relative paths are prefixed with './' when the output goes to a non interactive terminal
(TTY). Use this flag to disable this behaviour.
.B \-\-strip-cwd-prefix [when]
By default, relative paths are prefixed with './' when -x/--exec,
-X/--exec-batch, or -0/--print0 are given, to reduce the risk of a
path starting with '-' being treated as a command line option. Use
this flag to change this behavior. If this flag is used without a value,
it is equivalent to passing "always". Possible values are:
.RS
.IP auto
Use the default behavior.
.IP never
Never strip the ./ at the beginning of paths
.IP always
Always strip the ./ at the beginning of paths
.RE
.TP
.B \-\-one\-file\-system, \-\-mount, \-\-xdev
By default, fd will traverse the file system tree as far as other options dictate. With this flag, fd ensures that it does not descend into a different file system than the one it started in. Comparable to the -mount or -xdev filters of find(1).
@ -494,6 +502,17 @@ is set, use
.IR $XDG_CONFIG_HOME/fd/ignore .
Otherwise, use
.IR $HOME/.config/fd/ignore .
.SH FILES
.TP
.B .fdignore
This file works similarly to a .gitignore file anywhere in the searched tree and specifies patterns
that should be excluded from the search. However, this file is specific to fd, and will be used even
if the --no-ignore-vcs option is used.
.TP
.B $XDG_CONFIG_HOME/fd/ignore
Global ignore file. Unless ignore mode is turned off (such as with --no-ignore)
ignore entries in this file will be ignored, as if it was an .fdignore file in the
current directory.
.SH EXAMPLES
.TP
.RI "Find files and directories that match the pattern '" needle "':"
@ -507,6 +526,16 @@ $ fd -e py
.TP
.RI "Open all search results with vim:"
$ fd pattern -X vim
.SH Tips and Tricks
.IP \[bu]
If you add ".git/" to your global ignore file ($XDG_CONFIG_HOME/fd/ignore), then
".git" folders will be ignored by default, even when the --hidden option is used.
.IP \[bu]
You can use a shell alias or a wrapper script in order to pass desired flags to fd
by default. For example if you do not like the default behavior of respecting gitignore,
you can use
`alias fd="/usr/bin/fd --no-ignore-vcs"`
in your .bashrc to create an alias for fd that doesn't ignore git files by default.
.SH BUGS
Bugs can be reported on GitHub: https://github.com/sharkdp/fd/issues
.SH SEE ALSO

View File

@ -49,8 +49,7 @@ pub struct Opts {
no_hidden: (),
/// Show search results from files and directories that would otherwise be
/// ignored by '.gitignore', '.ignore', '.fdignore', the global ignore file,
/// or the default rule that excludes .git/.
/// ignored by '.gitignore', '.ignore', '.fdignore', or the global ignore file,
/// The flag can be overridden with --ignore.
#[arg(
long,
@ -64,7 +63,7 @@ pub struct Opts {
#[arg(long, overrides_with = "no_ignore", hide = true, action = ArgAction::SetTrue)]
ignore: (),
///Show search results from '.git/' folders and files and directories that
///Show search results from files and directories that
///would otherwise be ignored by '.gitignore' files.
///The flag can be overridden with --ignore-vcs.
#[arg(
@ -618,9 +617,10 @@ pub struct Opts {
/// By default, relative paths are prefixed with './' when -x/--exec,
/// -X/--exec-batch, or -0/--print0 are given, to reduce the risk of a
/// path starting with '-' being treated as a command line option. Use
/// this flag to disable this behaviour.
#[arg(long, conflicts_with_all(&["path", "search_path"]), hide_short_help = true, long_help)]
pub strip_cwd_prefix: bool,
/// this flag to change this behavior. If this flag is used without a value,
/// it is equivalent to passing "always".
#[arg(long, conflicts_with_all(&["path", "search_path"]), value_name = "when", hide_short_help = true, require_equals = true, long_help)]
strip_cwd_prefix: Option<Option<StripCwdWhen>>,
/// By default, fd will traverse the file system tree as far as other options
/// dictate. With this flag, fd ensures that it does not descend into a
@ -643,7 +643,7 @@ impl Opts {
} else if !self.search_path.is_empty() {
&self.search_path
} else {
let current_directory = Path::new(".");
let current_directory = Path::new("./");
ensure_current_directory_exists(current_directory)?;
return Ok(vec![self.normalize_path(current_directory)]);
};
@ -666,6 +666,9 @@ impl Opts {
fn normalize_path(&self, path: &Path) -> PathBuf {
if self.absolute_path {
filesystem::absolute_path(path.normalize().unwrap().as_path()).unwrap()
} else if path == Path::new(".") {
// Change "." to "./" as a workaround for https://github.com/BurntSushi/ripgrep/pull/2711
PathBuf::from("./")
} else {
path.to_path_buf()
}
@ -698,6 +701,16 @@ impl Opts {
.or_else(|| self.max_one_result.then_some(1))
}
pub fn strip_cwd_prefix<P: FnOnce() -> bool>(&self, auto_pred: P) -> bool {
use self::StripCwdWhen::*;
self.no_search_paths()
&& match self.strip_cwd_prefix.map_or(Auto, |o| o.unwrap_or(Always)) {
Auto => auto_pred(),
Always => true,
Never => false,
}
}
#[cfg(feature = "completions")]
pub fn gen_completions(&self) -> anyhow::Result<Option<Shell>> {
self.gen_completions
@ -758,6 +771,16 @@ pub enum ColorWhen {
Never,
}
#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum)]
pub enum StripCwdWhen {
/// Use the default behavior
Auto,
/// Always strip the ./ at the beginning of paths
Always,
/// Never strip the ./
Never,
}
// there isn't a derive api for getting grouped values yet,
// so we have to use hand-rolled parsing for exec and exec-batch
pub struct Exec {

View File

@ -128,13 +128,11 @@ pub fn strip_current_dir(path: &Path) -> &Path {
pub fn default_path_separator() -> Option<String> {
if cfg!(windows) {
let msystem = env::var("MSYSTEM").ok()?;
match msystem.as_str() {
"MINGW64" | "MINGW32" | "MSYS" => Some("/".to_owned()),
_ => None,
if !msystem.is_empty() {
return Some("/".to_owned());
}
} else {
None
}
None
}
#[cfg(test)]

View File

@ -311,8 +311,7 @@ fn construct_config(mut opts: Opts, pattern_regexps: &[String]) -> Result<Config
path_separator,
actual_path_separator,
max_results: opts.max_results(),
strip_cwd_prefix: (opts.no_search_paths()
&& (opts.strip_cwd_prefix || !(opts.null_separator || has_command))),
strip_cwd_prefix: opts.strip_cwd_prefix(|| !(opts.null_separator || has_command)),
})
}

View File

@ -334,10 +334,6 @@ impl WorkerState {
.map_err(|e| anyhow!("Malformed exclude pattern: {}", e))?;
}
if config.read_vcsignore {
builder.add("!.git/").expect("Invalid exclude pattern");
}
builder
.build()
.map_err(|_| anyhow!("Mismatch in exclude patterns"))

View File

@ -2573,7 +2573,14 @@ fn test_git_dir() {
],
);
te.assert_output(&["--hidden", "foo"], "");
te.assert_output(
&["--hidden", "foo"],
".git/one/foo.a
.git/.foo
.git/a.foo
other_dir/.git/foo1
nested/dir/.git/foo2",
);
te.assert_output(&["--no-ignore", "foo"], "");
te.assert_output(
&["--hidden", "--no-ignore", "foo"],
@ -2592,3 +2599,16 @@ fn test_git_dir() {
nested/dir/.git/foo2",
);
}
#[test]
fn test_gitignore_parent() {
let te = TestEnv::new(&["sub"], &[".abc", "sub/.abc"]);
fs::File::create(te.test_root().join(".gitignore"))
.unwrap()
.write_all(b".abc\n")
.unwrap();
te.assert_output_subdirectory("sub", &["--hidden"], "");
te.assert_output_subdirectory("sub", &["--hidden", "--search-path", "."], "");
}