Skip to content

Add xff/repo + -g auto mode: respect .gitignore only in a git repo (#95) - #222

Merged
helly25 merged 1 commit into
mainfrom
feat/repo-gitignore-auto
Jul 3, 2026
Merged

Add xff/repo + -g auto mode: respect .gitignore only in a git repo (#95)#222
helly25 merged 1 commit into
mainfrom
feat/repo-gitignore-auto

Conversation

@helly25

@helly25 helly25 commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

First slice of #95's gitignore refinements: a repo-discovery module and the auto semantics of the -g ternary.

  • New xff/repo module. FindRepoRoot(fs, start_dir) walks up from a search root to the git working-tree root - the first ancestor holding a .git (a directory for a normal checkout, or a file for a worktree/submodule pointer; existence via VFS Stat is enough). Returns nullopt when no ancestor is a repo. Pure and VFS-backed, so a fake filesystem drives the unit tests.
  • -g / --gitignore ternary. Bare -g / --gitignore now means auto: respect per-directory .gitignore only when a search root is inside a git repo (git's own behavior). --gitignore=on forces it on regardless; --gitignore=off forces it off. Last occurrence wins; still off by default (find-compatible), and -u / --no-ignore still overrides everything. (Previously bare -g was unconditional on.)

Self-documentation

--gitignore GlobalFlag summary + the kHelpText line describe the ternary; design.md marks what shipped vs pending.

Tests

  • xff/repo:repo_test (unit, fake fs): start-dir hit, ancestor walk, nearest-of-nested wins, .git file counts, filesystem-root repo, nullopt cases.
  • ignore_gitignore_test.sh (e2e): bare -g auto-on inside a repo, auto-off outside, --gitignore=on forces outside a repo, =off / -u disable. The fixture plants an empty .git (contributes no -type f entries).

bazel test //... green (43); both clang-format versions + shfmt/shellcheck clean.

Follow-ups (remain under #95)

-g+ / -g- short spellings, .git/info/exclude, and global core.excludesFile - each a separate small PR building on this module.

New xff/repo module: FindRepoRoot walks up from a search root to the git
working-tree root (the first ancestor with a .git dir or file), probed via
the VFS (Stat), so a fake filesystem drives the unit tests.

Wire it into the -g / --gitignore ternary: bare -g / --gitignore now selects
AUTO (respect per-directory .gitignore only when a search root is inside a
git repo, matching git's own behavior), while --gitignore=on forces it on
regardless and --gitignore=off forces it off. Last occurrence wins; still
off by default (find-compatible), and -u / --no-ignore still overrides.
Previously bare -g meant unconditional on.

Self-doc: --gitignore GlobalFlag summary + kHelpText line describe the
ternary; design.md notes what shipped vs pending. Tests: repo_test (unit,
fake fs) + ignore_gitignore_test.sh (e2e: auto-on in a repo, auto-off
outside, =on forces outside, =off/-u disable).

Follow-ups (still #95): -g+/-g- short spellings, .git/info/exclude, and
core.excludesFile.
@helly25
helly25 enabled auto-merge (squash) July 3, 2026 08:22
@helly25
helly25 merged commit 6b03e41 into main Jul 3, 2026
14 of 16 checks passed
@helly25
helly25 deleted the feat/repo-gitignore-auto branch July 3, 2026 17:51
@helly25
helly25 restored the feat/repo-gitignore-auto branch July 3, 2026 18:37
@helly25
helly25 deleted the feat/repo-gitignore-auto branch July 3, 2026 18:38
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