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

Files committed to a git repo that also match .gitignore are not searched #2075

Closed
infokiller opened this issue Nov 17, 2021 · 1 comment
Closed
Labels
duplicate An issue that is duplicative of another.

Comments

@infokiller
Copy link

What version of ripgrep are you using?

Replace this text with the output of rg --version.

ripgrep 13.0.0 (rev 7ec2fd51ba)
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)

How did you install ripgrep?

Github binary release.

What operating system are you using ripgrep on?

Linux 5.14.16-hardened1-1-hardened

Describe your bug.

ripgrep doesn't show files committed to a git repo if t hey are also ignored. git ls-files works correctly.
Seems related to #778

What are the steps to reproduce the behavior?

build_oci_img () {
  docker build "$@" - <<'EOF'
  FROM rust:1.56.1-slim-bullseye
  RUN apt-get update && apt-get install -y --no-install-recommends git curl bash
  RUN curl -fsSL https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep_13.0.0_amd64.deb -o ripgrep.deb && dpkg -i ripgrep.deb
  # Required for git init to work
  RUN git config --global user.email test@mail.com && git config --global user.name test
  WORKDIR /repo
  RUN git -c init.defaultBranch=master init
EOF
}

docker run --rm -i --entrypoint=bash "$(build_oci_img -q)" <<-'EOF'
  set -x
  git --version
  rg --version
  touch file
  git add file
  git commit -m test
  git ls-files
  rg --files
  echo file > .gitignore
  git ls-files
  rg --debug --files
EOF

What is the actual behavior?

> rg --debug --files
DEBUG|globset|crates/globset/src/lib.rs:421: built glob set; 0 literals, 1 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|ignore::walk|crates/ignore/src/walk.rs:1741: ignoring ./.gitignore: Ignore(IgnoreMatch(Hidden))
DEBUG|ignore::walk|crates/ignore/src/walk.rs:1741: ignoring ./.git: Ignore(IgnoreMatch(Hidden))
DEBUG|ignore::walk|crates/ignore/src/walk.rs:1741: ignoring ./file: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("./.gitignore"), original: "file", actual: "**/file", is_whitelist: false, is_only_dir: false })))

What is the expected behavior?

Show the files if they are part of the git repo like git ls-files does, even if they match git ignore.

@BurntSushi
Copy link
Owner

Dupe of #1530.

@BurntSushi BurntSushi added the duplicate An issue that is duplicative of another. label Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate An issue that is duplicative of another.
Projects
None yet
Development

No branches or pull requests

2 participants