Repository navigation
feat: add untracked/staged file support (u toggle + s stage/unstage) - #55
sanchesfree wants to merge 4 commits into
Conversation
d1f2c45 to
34e7340
Compare
Rebased on upstream/master with FileEntry API adaptation. - u toggle shows/hides untracked files in file tree - s key stages untracked files / unstages staged-by-revdiff files - Added UntrackedFiles() to Renderer interface and all implementations - Added ReadFileAsAdded for rendering untracked/staged files as all-added lines - Fallback in handleFileLoaded for untracked/staged files with empty diff - Status bar shows ? icon when untracked mode active
7c6a740 to
6150d92
Compare
umputun
left a comment
There was a problem hiding this comment.
thx for the effort, I can see this is well-tested with solid code quality. however, I can't merge this for a few reasons.
revdiff is a read-only review tool. adding git add and git restore --staged turns it into a staging tool, which is a different category. I don't want revdiff to mutate git state, the whole point is it's safe to run on any repo without side effects.
issue #48 is already fixed in ce35fb0 - the detect-ref script handles fresh repos and falls back to --all-files mode. the user just needs to git add first, which is the normal workflow anyway.
interface pollution - UntrackedFiles() forced onto all 6 Renderer implementations when only Git has real logic, the rest return nil, nil.
I appreciate the work, especially the test coverage. if showing untracked files turns out to be needed, it's a ~20 line change to DirectoryReader, not a 1000+ line feature with git mutations.
Hi! First off — apologies if this falls outside the original vision for revdiff. I might be misunderstanding the concept, but man, I really missed being able to browse untracked files and stage/unstage them right from the TUI. Like, a lot. So here we go.
What this adds
u— toggle untracked files in the treePress
uto show/hide untracked files (fromgit ls-files --others --exclude-standard) alongside changed files in the file tree. Untracked files get a?prefix, staged files get a+prefix.s— stage / unstage the selected fileson an untracked file →git addson a file you staged via revdiff →git restore --stagedStaged-only files (auto-discovered)
Files that exist in
git diff --cachedbut have no unstaged changes are automatically included in the tree (not gated behind theutoggle). These are real working changes, not "untracked."Other bits
+) since there's no previous version to diff against?mode icon in the status bar when untracked files are visible[s] stage/[s] unstagehint in the status bar when cursor is on an applicable fileuis on but none existReadFileAsAddedfor files with empty diff (covers both untracked and staged-only)Interface changes
UntrackedFiles()to theui.Rendererinterface (and internaldiff.renderer)ReadFileAsAdded()todiffpackage for reading files as all-addedDiffLinesUntrackedFiles()implemented on all renderers:Git,FallbackRenderer,FileReader,DirectoryReader,ExcludeFilter,StdinReaderTesting
17 new tests covering toggle, fetchStagedOnly, handleStaged (duplicates, unstage, preserves others), handleStage guards, handleFileLoaded fallback, and error handling. UI coverage: 93.5%.
Keybindings
usBoth are configurable via
~/.config/revdiff/keybindings.Let me know if this is useful or if I'm totally off base with the direction. Happy to adjust!