Skip to content

Add -g / --gitignore: respect per-directory .gitignore (ignore family, PR 4/4) - #201

Merged
helly25 merged 2 commits into
mainfrom
feat/ignore-gitignore
Jul 1, 2026
Merged

Add -g / --gitignore: respect per-directory .gitignore (ignore family, PR 4/4)#201
helly25 merged 2 commits into
mainfrom
feat/ignore-gitignore

Conversation

@helly25

@helly25 helly25 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

PR 4 of 4 - completes the core ignore family (task #80). -g / --gitignore makes xff respect a .gitignore in every directory, reusing the #199 per-directory stack (deeper overrides shallower). Off by default (find-compatible); --gitignore=off disables, and -u / --no-ignore stays the master switch over every source.

  • run.cc: GitignoreEnabled (last occurrence wins, =off disables); ResolveIgnoreFileNames now composes the per-directory filename list from all sources, lowest precedence first: .gitignore (-g) < .ignore < .xffignore (--ignore-files), so within a directory the xff-specific file wins. -u/--no-ignore -> none.
  • Self-doc (same change): --gitignore (alias -g) in the Ignore / filter group (-> --help/--man/--markdown) + kHelpText.

Tests: cli/ignore_gitignore_test.sh - off by default, -g respects recursively, =off and -u disable, a nested .gitignore scopes to its subtree, --help=-g topic. bazel test //... green (33 tests).

Scope note: bare -g means on today. The design's bare-g=auto (respect iff in a git repo), .git/info/exclude, global core.excludesFile, and the -g+/-g- suffix-sign spelling need git-repo detection + toggle-parser machinery not built yet - tracked as a follow-up (task #95).

With this the ignore family core is complete: --exclude/--include, --ignore-files (.ignore/.xffignore), -g (.gitignore), and -u/--no-ignore, all on one per-directory matcher.

…, PR 4/4)

Completes the core ignore family: -g / --gitignore makes xff respect a .gitignore
in every directory, reusing the #199 per-directory stack (deeper overrides
shallower). Off by default (find-compatible); --gitignore=off turns it back off, and
-u / --no-ignore remains the master switch over every source.

- run.cc: GitignoreEnabled(globals) (last occurrence wins, =off disables);
  ResolveIgnoreFileNames now builds the per-directory filename list from all sources,
  lowest precedence first: .gitignore (-g) < .ignore < .xffignore (--ignore-files),
  so within a directory the xff-specific file wins. -u/--no-ignore returns none.

Self-documentation (same change): --gitignore (alias -g) GlobalFlag in the Ignore /
filter group (flow into --help / --man / --markdown) + the kHelpText usage page.

cli/ignore_gitignore_test.sh: off by default, -g respects recursively, =off and
-u/--no-ignore disable, a nested .gitignore scopes to its subtree, --help topic.

Scope note: bare -g means ON today. The design's bare-g=auto (respect iff in a git
repo), .git/info/exclude, global core.excludesFile, and the -g+/-g- suffix-sign
spelling need git-repo detection + toggle-parser machinery not built yet; tracked as
a follow-up (#95). bazel test //... green (33 tests).
@helly25
helly25 enabled auto-merge (squash) July 1, 2026 23:39
…c failure

The --help=-g assertion flaked once on the ubuntu clang-asan CI cell (intermittent,
not reproducible on macOS-asan / ubuntu-default / locally) as a bare 'substring
missing', hiding the xff subprocess's captured stderr. Assert the exit status and
print the captured output on mismatch so a recurrence shows the real cause (e.g. a
sanitizer abort) rather than masquerading. Diagnostic + stricter; no behavior change.
@helly25
helly25 merged commit e31ffbe into main Jul 1, 2026
8 checks passed
@helly25
helly25 deleted the feat/ignore-gitignore branch July 1, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant