[Git] Add DiffUntracked to render untracked file contents - #41
Merged
Conversation
This was referenced Jul 26, 2026
KCaverly
force-pushed
the
ct/diff_view/536182cd
branch
from
July 26, 2026 19:23
1e6423c to
4b74429
Compare
KCaverly
force-pushed
the
ct/diff_view/303beec7
branch
from
July 26, 2026 19:23
b591f18 to
8644387
Compare
The diff viewer lists untracked files by name in its file index but shows nothing of what is in them, because `git diff HEAD` never reports a file git isn't tracking. For a brand-new file that leaves the most interesting part invisible — the contents are the whole change. DiffUntracked diffs each path against os.DevNull with `git diff --no-index`, which renders it as a whole-file addition beneath an ordinary `diff --git` header. That shape matters: the diff builder indexes those headers for its file-jump keys and colours the + lines, so new files behave like tracked ones with no styler changes. Binary files collapse to git's one-line notice rather than inlining their bytes. --no-index follows diff(1) and signals "the inputs differ" with exit 1, which Git treats as failure. Rather than a second runner, Git now delegates to an internal git() that takes one forgivable exit code; -1 (accept only 0) keeps every existing caller's behaviour byte-identical. Only an ExitError is forgiven, so a timeout or a missing binary still fails. Per-path errors are skipped rather than propagated. An untracked file is by definition outside git's control and can vanish between the status call that listed it and this one; losing every other file's diff to that race would be the wrong trade. Caller-driven path list: each file costs a subprocess, so the cap belongs with the caller that knows what it is willing to render. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> ct-stack-id: 303beec7
KCaverly
force-pushed
the
ct/diff_view/303beec7
branch
from
July 26, 2026 19:30
8644387 to
88bf444
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The diff viewer lists untracked files by name in its file index but shows
nothing of what is in them, because
git diff HEADnever reports a file gitisn't tracking. For a brand-new file that leaves the most interesting part
invisible — the contents are the whole change.
DiffUntracked diffs each path against os.DevNull with
git diff --no-index,which renders it as a whole-file addition beneath an ordinary
diff --githeader. That shape matters: the diff builder indexes those headers for its
file-jump keys and colours the + lines, so new files behave like tracked ones
with no styler changes. Binary files collapse to git's one-line notice rather
than inlining their bytes.
--no-index follows diff(1) and signals "the inputs differ" with exit 1, which
Git treats as failure. Rather than a second runner, Git now delegates to an
internal git() that takes one forgivable exit code; -1 (accept only 0) keeps
every existing caller's behaviour byte-identical. Only an ExitError is
forgiven, so a timeout or a missing binary still fails.
Per-path errors are skipped rather than propagated. An untracked file is by
definition outside git's control and can vanish between the status call that
listed it and this one; losing every other file's diff to that race would be
the wrong trade.
Caller-driven path list: each file costs a subprocess, so the cap belongs
with the caller that knows what it is willing to render.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Stack (bottom → top):