Skip to content

ignore: WalkBuilder.add_ignore() patterns are not rooted in the path being walked #1394

Open
@dragonmaus

Description

@dragonmaus

Alternative title: No way to specify "root path" for WalkBuilder.add_ignore()

Describe your question, feature request, or bug.

When building an instance of Walk using ignore::WalkBuilder, the patterns in files added by .add_ignore() are matched against the current working directory of the process, instead of the root of the tree being Walked.

If this is a bug, what are the steps to reproduce the behavior?

After downloading the files in this gist, perform the following steps:

mkdir src
mv main.rs src
cargo build --release
target/release/test -I ignore .              # this is "Test 1"
cd ..
test/target/release/test -I test/ignore test # this is "Test 2"

If this is a bug, what is the actual behavior?

Test 1 produces the expected output:

.
./Cargo.lock
./Cargo.toml
./ignore
./src
./src/main.rs

Test 2, however, also includes the contents of the target directory (full output here).

If this is a bug, what is the expected behavior?

Test 2 should produce the following output:

test
test/Cargo.lock
test/Cargo.toml
test/ignore
test/src
test/src/main.rs

Changing the pattern in the file ignore to /test/target/ produces the desired results, but is not what I would expect (or want) to have to do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug.gitignoreBugs related to gitignore problems.questionAn issue that is lacking clarity on one or more points.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions