Repository navigation
feat(git): add per-file git-LFS smudge toggle (gl) - #374
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical defects can silently discard unsaved edits, stage full LFS payloads instead of pointers, and freeze or exhaust the editor during unbounded file probes.
9 open issues
Check file size before probing LOCAL content with readfile · New Prevent toggling off when owned buffers have unsaved edits · New Apply the LFS clean filter when saving editable stage buffers · New Leave fast-event context before handling recompute failures · New Recompute smudged stats on refresh and preserve updated raw counts · New Handle missing git-lfs when registering describe checks · New Override GIT_LFS_SKIP_SMUDGE for explicit smudge operations · New Route LFS pointers before binary suppression and refresh binary state · New Refresh cached LOCAL LFS snapshots when working-tree files change · New
What changed in this PR
Adds an opt-in, per-file Git LFS content view to Diffview, allowing users to switch between pointer files and expanded content with gl.
Changes:
- Adds the toggle action, keybindings, buffer reloading, and content-level change counts.
- Implements LFS detection, smudging, working-tree pointer generation, and size limits.
- Adds functional tests and documents the feature.
| File | Description |
|---|---|
lua/diffview/vcs/file.lua |
Adds LFS-aware content loading and buffer naming. |
lua/diffview/vcs/adapters/git/lfs.lua |
Implements LFS helpers and content-level statistics. |
lua/diffview/tests/functional/git_lfs_spec.lua |
Tests pointers, smudging, statistics, and size limits. |
lua/diffview/scene/views/diff/listeners.lua |
Handles toggling, rollback, and display updates. |
lua/diffview/scene/file_entry.lua |
Preserves LFS state across layout changes. |
lua/diffview/config.lua |
Binds gl in diff buffers and the file panel. |
lua/diffview/actions.lua |
Registers the LFS toggle action. |
doc/diffview.txt |
Documents usage, requirements, and the size cap. |
doc/diffview_changelog.txt |
Announces the LFS toggle feature. |
Review effort: Balanced
Comment on lines
+843
to
+844
| local ok, sample = | ||
| pcall(vim.fn.readfile, pl:absolute(p, view.adapter.ctx.toplevel), "", 11) |
Comment on lines
+861
to
+870
| item._lfs_toggle_gen = (item._lfs_toggle_gen or 0) + 1 | ||
| local my_gen = item._lfs_toggle_gen | ||
|
|
||
| local new_state = not item.lfs_smudge | ||
| item.lfs_smudge = new_state | ||
|
|
||
| for _, f in ipairs(utils.vec_join(item.layout:owned_files(), item._extra_owned)) do | ||
| f.lfs_smudge = new_state | ||
| f:dispose_buffer() | ||
| end |
Comment on lines
+326
to
+328
| local serr, smudged = await(git_lfs.smudge(self.adapter, self.path, data)) | ||
| if smudged then | ||
| data = smudged |
| end | ||
| local stats, status = | ||
| await(git_lfs.recompute_stats(view.adapter, path_a, item.revs.a, path_b, item.revs.b)) | ||
| if item._lfs_toggle_gen == my_gen then |
Comment on lines
+910
to
+911
| item.stats.additions = stats.additions | ||
| item.stats.deletions = stats.deletions |
Comment on lines
+14
to
+15
| local res = vim.system({ "git-lfs", "version" }, { text = true }):wait() | ||
| return res.code == 0 |
| job = Job({ | ||
| command = adapter:bin(), | ||
| args = utils.vec_join(adapter:args(), "lfs", "smudge", "--", path), | ||
| cwd = adapter.ctx.toplevel, |
Comment on lines
+451
to
+452
| local git_lfs = require("diffview.vcs.adapters.git.lfs") | ||
| local is_lfs = await(self:_lfs_tracked()) |
Comment on lines
+463
to
+465
| -- Pointer-view: route through `diffview://` so both sides diff | ||
| -- as pointers. | ||
| use_diffview_buf = true |
dlyongemallo
force-pushed
the
support_git_lfs
branch
from
November 3, 2026 13:58
ca40739 to
78b9470
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.


No description provided.