Skip to content

grep: exempt the implicit '.' walk root from --exclude-dir - #242

Open
draarivpatel-ui wants to merge 2 commits into
uutils:mainfrom
draarivpatel-ui:exclude-dir-implicit-cwd
Open

draarivpatel-ui wants to merge 2 commits into
uutils:mainfrom
draarivpatel-ui:exclude-dir-implicit-cwd

Conversation

@draarivpatel-ui

Copy link
Copy Markdown

With -r and no file operand, GNU grep searches the current directory but never matches that implicit . against --exclude-dir. uutils checked the walk root like any other directory, so grep -r --exclude-dir='.*' PATTERN (the common idiom for skipping hidden dirs such as .git) excluded the root itself and searched nothing.

The walk already knows this case: strip_root is set only by process_implicit_cwd. The fix skips the exclude-dir test for the depth-0 entry in that case. An explicit . operand is unchanged and is still excludable.

Closes #165

Copilot AI balanced review requested due to automatic review settings November 24, 2026 19:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.11%. Comparing base (83db14b) to head (f39c4d6).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #242      +/-   ##
==========================================
+ Coverage   97.12%   98.11%   +0.98%     
==========================================
  Files           6        6              
  Lines        2227     2229       +2     
  Branches      241      243       +2     
==========================================
+ Hits         2163     2187      +24     
+ Misses         64       42      -22     
Flag Coverage Δ
macOS_latest 98.11% <100.00%> (+0.06%) ⬆️
ubuntu_latest 98.11% <100.00%> (+0.06%) ⬆️
windows_latest ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

Warning

uutils has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed.

1 warning

⚠️ 3 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 10 untouched benchmarks
⏩ 17 skipped benchmarks1


Comparing draarivpatel-ui:exclude-dir-implicit-cwd (f39c4d6) with main (b2fd25a)

Open in CodSpeed

Footnotes

  1. 17 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@github-actions

Copy link
Copy Markdown

GNU grep testsuite comparison:

Test results comparison:
  Current:   TOTAL: 128 / PASSED: 77 / FAILED: 30 / SKIPPED: 21
  Reference: TOTAL: 128 / PASSED: 76 / FAILED: 31 / SKIPPED: 21

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + include-exclude

Comment thread tests/test_grep.rs

let mut c = scene.cmd(env!("CARGO_BIN_EXE_grep"));
c.current_dir(scene.fixtures.plus("flat"))
.args(&["-r", "--exclude-dir=.*", "grep"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please also cover --exclude-dir=. without an operand? the issue has both cases
it should then find .hidden/h.txt too

Copilot AI balanced review requested due to automatic review settings November 25, 2026 16:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

Copy link
Copy Markdown

GNU grep testsuite comparison:

Test results comparison:
  Current:   TOTAL: 128 / PASSED: 77 / FAILED: 30 / SKIPPED: 21
  Reference: TOTAL: 128 / PASSED: 76 / FAILED: 31 / SKIPPED: 21

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + include-exclude

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.

grep - grep -r --exclude-dir='.*' with no path excludes the implicit . and searches nothing

3 participants