Add xff/repo + -g auto mode: respect .gitignore only in a git repo (#95) - #222
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First slice of #95's gitignore refinements: a repo-discovery module and the auto semantics of the
-gternary.xff/repomodule.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 VFSStatis enough). Returns nullopt when no ancestor is a repo. Pure and VFS-backed, so a fake filesystem drives the unit tests.-g/--gitignoreternary. Bare-g/--gitignorenow means auto: respect per-directory.gitignoreonly when a search root is inside a git repo (git's own behavior).--gitignore=onforces it on regardless;--gitignore=offforces it off. Last occurrence wins; still off by default (find-compatible), and-u/--no-ignorestill overrides everything. (Previously bare-gwas unconditional on.)Self-documentation
--gitignoreGlobalFlag summary + thekHelpTextline describe the ternary;design.mdmarks what shipped vs pending.Tests
xff/repo:repo_test(unit, fake fs): start-dir hit, ancestor walk, nearest-of-nested wins,.gitfile counts, filesystem-root repo, nullopt cases.ignore_gitignore_test.sh(e2e): bare-gauto-on inside a repo, auto-off outside,--gitignore=onforces outside a repo,=off/-udisable. The fixture plants an empty.git(contributes no-type fentries).bazel test //...green (43); both clang-format versions + shfmt/shellcheck clean.Follow-ups (remain under #95)
-g+/-g-short spellings,.git/info/exclude, and globalcore.excludesFile- each a separate small PR building on this module.