Skip to content

fix: use numstat to filter whitespace-only changes with -W flag#1217

Merged
scolladon merged 7 commits intomainfrom
fix/whitespace-numstat-filtering
Feb 20, 2026
Merged

fix: use numstat to filter whitespace-only changes with -W flag#1217
scolladon merged 7 commits intomainfrom
fix/whitespace-numstat-filtering

Conversation

@scolladon
Copy link
Copy Markdown
Owner

@scolladon scolladon commented Feb 20, 2026

Explain your changes


Fixes regression introduced in commit 8244258 where the -W (ignore whitespace) flag incorrectly includes files with only whitespace changes in the delta package.

Root cause: git diff --name-status ignores whitespace flags for file reporting — a file with only whitespace changes still appears as M. The previous implementation (v6.19.0) used git diff --numstat with per-change-type queries, where whitespace flags cause such files to produce 0 0 stats and --diff-filter=M naturally excludes them.

Fix: Revert getDiffLines() from a single --name-status --diff-filter=AMD call to 3 sequential --numstat --diff-filter=X calls (one per change type: A, M, D). Output format (X\tpath) is unchanged — no downstream changes needed.

Additional improvement: Replaced all 5 push(...spread) occurrences across the codebase with a stack-safe pushAll utility to prevent potential RangeError on large arrays.

Does this close any currently open issues?


Nop

  • Jest tests added to cover the fix.
  • NUT tests added to cover the fix.
  • E2E tests added to cover the fix.

Any particular element that can be tested locally


Use -W flag with two commits where a file has only whitespace changes (e.g., a blank line removed). The file should NOT appear in the generated package.xml:

sf sgd source delta --from <commit-before> --to <commit-after> -W --output-dir output

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f3fce5a) to head (8351325).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1217   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           57        58    +1     
  Lines         1528      1542   +14     
  Branches       194       194           
=========================================
+ Hits          1528      1542   +14     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

Published under dev-1217 npm channel.

$ sf plugins install sf-git-merge-driver@dev-1217

@scolladon scolladon merged commit d5cda86 into main Feb 20, 2026
21 of 24 checks passed
@scolladon scolladon deleted the fix/whitespace-numstat-filtering branch February 20, 2026 10:35
@github-actions
Copy link
Copy Markdown

Shipped in release v6.32.2.
Version v6.32.2 will be assigned to the latest npm channel soon
Install it using either v6.32.2 or the latest-rc npm channel

$ sf plugins install sfdx-git-delta@latest-rc
# Or
$ sf plugins install sfdx-git-delta@v6.32.2

💡 Enjoying sfdx-git-delta?
Your contribution helps us provide fast support 🚀 and high quality features 🔥
Become a sponsor 💙
Happy incremental deployment!

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