Skip to content

Comments

Fix binary file numbering and filtering (#157)#162

Merged
twaugh merged 3 commits into0.4.xfrom
issue-157
Feb 23, 2026
Merged

Fix binary file numbering and filtering (#157)#162
twaugh merged 3 commits into0.4.xfrom
issue-157

Conversation

@twaugh
Copy link
Owner

@twaugh twaugh commented Feb 23, 2026

Description

Fixes #157.

Type of Change

  • Bug fix (targets 0.4.x)
  • New feature (targets master)
  • Documentation update
  • Other (please describe)

Testing

Test cases added.

Two test cases added to reproduce GitHub issue #157, where binary
files are incorrectly counted and filtered since commit bfab1d2.

The lsdiff-binary-numbering test demonstrates that binary files
get duplicate file numbers instead of sequential numbering.

The filterdiff-binary-filtering test demonstrates that binary
files leak through file number filters.

Both tests currently fail and will pass once issue #157 is fixed.

Assisted-by: Claude Code
Binary files were not incrementing the file counter, causing them
to display duplicate file numbers when using lsdiff -N.

The issue occurs in git diffs without hunks (binary files, mode
changes, pure renames). These files break out of header processing
and are handled separately by do_git_diff_no_hunks(), bypassing
the normal filecount++ that happens when processing +++ headers.

This fix adds filecount++ in both code paths that handle git diffs
without hunks:
- EOF case: when git headers are found at end of file
- Non-EOF case: when git headers are followed by binary content

With this fix, binary files are numbered sequentially like text files.

Assisted-by: Claude Code
Binary files were not respecting the -F file number filter, causing
them to appear in output even when their file number didn't match
the requested range.

The issue occurs because git diffs without hunks (binary files, mode
changes, pure renames) bypass the normal hunk processing where
file_matches() is called. These files check pattern filters (-i/-x)
but never check the file number filter (-F).

This fix adds file_matches() checks in both code paths that handle
git diffs without hunks:
- EOF case: when git headers are found at end of file
- Non-EOF case: when git headers are followed by binary content

With this fix, binary files respect -F filtering just like text files.

Assisted-by: Claude Code
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.60%. Comparing base (f8f3b58) to head (d54663f).
⚠️ Report is 4 commits behind head on 0.4.x.

Additional details and impacted files
@@            Coverage Diff             @@
##            0.4.x     #162      +/-   ##
==========================================
+ Coverage   83.51%   83.60%   +0.09%     
==========================================
  Files           5        5              
  Lines        4167     4173       +6     
  Branches      995      997       +2     
==========================================
+ Hits         3480     3489       +9     
+ Misses        687      684       -3     
Flag Coverage Δ
unittests 83.60% <100.00%> (+0.09%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@twaugh twaugh merged commit cdb78ff into 0.4.x Feb 23, 2026
7 checks passed
@twaugh twaugh deleted the issue-157 branch February 23, 2026 11:57
twaugh added a commit that referenced this pull request Feb 23, 2026
Document the binary file handling fixes merged in PR #162:
- Binary files now get sequential file numbers with lsdiff -N
- Binary file messages now respect filterdiff -F filtering
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