--ignore-files: negated pattern in a nested .gitignore is ignored when the search starts above that directory

Aperta
#581 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
cli, search

Direzione di ricerca

Start by tracing how ugrep --ignore-files reads nested .gitignore files and applies negated patterns when traversal begins above the directory containing them. Reproduce with the provided shell commands, then compare root-level and sub-level searches. Done when both searches list sub/include/perf/api.h while continuing to exclude sub/perf/bin.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version: ugrep 7.8.5 (debian:testing, aarch64) and 7.8.4 (macOS arm64, bundled in Claude Code). Not checked against master.

Reproduction

mkdir -p sub/include/perf sub/perf
printf 'perf\n!include/perf/\n' > sub/.gitignore
echo needle > sub/include/perf/api.h
echo needle > sub/other.c
echo x > sub/perf/bin        # control: ignored by `perf`

ugrep --ignore-files -rl needle .
# sub/other.c

(cd sub && ugrep --ignore-files -rl needle .)
# include/perf/api.h
# other.c

Expected: sub/include/perf/api.h is listed in both cases. gitignore(5): a ! pattern re-includes a path excluded by a previous pattern, provided its parent directory is not excluded; here the parent sub/include/ is not. git agrees: git check-ignore -v --no-index sub/include/perf/api.h exits 1 (not ignored), while a control file sub/perf/bin is reported ignored by sub/.gitignore:1:perf.

Real-world case: the Linux kernel's tools/perf/.gitignore has perf followed by !include/perf/. Searching from the kernel root with --ignore-files omits tools/perf/include/perf/perf_dlfilter.h, the canonical definition of struct perf_dlfilter_fns, while still returning documentation and test copies (exit 0). Started from tools/perf/, the header is found.

Impact note: Claude Code's native macOS/Linux builds run grep as ugrep --ignore-files -I ..., so AI coding agents hit this on recursive searches from a repository root. Survey and scripts: https://github.com/bsbhadwal/claude-code-grep-survey

Thanks for ugrep.

Lingua principale
C++
Stelle
3.3k
Fork
148
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Genivia/ugrep

Tutte le issue di Genivia/ugrep

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.