Skip to content

grep: separate context groups across files - #131

Open
SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:context-separator-across-files
Open

SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:context-separator-across-files

Conversation

@SichenLiang

Copy link
Copy Markdown
Contributor

Track whether an earlier file printed a context group so that the first group in a later file receives a separator. The existing line-gap check still decides when two groups within the same file need one.

Tests cover the default separator, --no-group-separator, a custom separator, and recursive searches over two directories.

One case remains: if a binary file matches before a text file, GNU starts the text output with a separator, while this change does not. For example:

printf 'hit\0\n' > binary
printf 'hit\n' > text
grep -C0 hit binary text

GNU stdout begins with --\ntext:hit\n; this change prints text:hit\n. Both report the binary match on stderr and exit 0.

Fixes #130

Track whether a previous file printed a context group so the first group
in a later file receives a separator. Within a file, continue to
separate only groups with a gap between their printed lines.

Cover the default, disabled and custom separators, including recursive
searches across two directories.
@codspeed

codspeed Bot commented Oct 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 17 skipped benchmarks1


Comparing SichenLiang:context-separator-across-files (103c65a) with main (381695b)

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. ↩

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: context output omits group separators between files

1 participant