Add per-file line counts to the source control sidebar (#2865)

* Add per-file line counts to the source control sidebar

Show +N/-N (green/red) next to each file in the Changes, Untracked, and
Committed-on-branch sections so the magnitude of a change is visible at a
glance. Counts are computed per staging area via `git diff --numstat`;
untracked/new files count their full contents as additions and binary
files show no count.

Consolidate numstat parsing and binary-buffer detection into shared
modules reused by the local status path, the SSH/relay path, and the
existing branch-compare code. Include added/removed in the status-entry
equality check so the sidebar doesn't re-render on unchanged polls.

* fix: harden source control line counts

---------

Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
This commit is contained in:
Trevin Chow
2026-05-26 20:09:54 -07:00
committed by GitHub
co-authored by Neil
parent 6a9be249f5
commit b2b5cac9a9
15 changed files with 660 additions and 133 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
import { readBlobAtOid, type GitBufferExec, type GitExec } from './git-handler-ops'
import { buildDiffResult, parseBranchDiff, parseBranchDiffNumstat } from './git-handler-utils'
import { buildDiffResult, parseBranchDiff } from './git-handler-utils'
import { parseNumstat } from '../shared/git-uncommitted-line-stats'
const FULL_GIT_OBJECT_ID_PATTERN = /^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$/
@@ -103,7 +104,7 @@ export async function commitCompare(git: GitExec, worktreePath: string, commitId
git(diffArgs, worktreePath),
git(numstatArgs, worktreePath)
])
const entries = parseBranchDiff(stdout, parseBranchDiffNumstat(numstat))
const entries = parseBranchDiff(stdout, parseNumstat(numstat))
summary.changedFiles = entries.length
return { summary, entries }
} catch (error) {