Skip to content

feat(git): add per-file git-LFS smudge toggle (gl) - #374

Merged
dlyongemallo merged 1 commit into
mainfrom
support_git_lfs
Nov 3, 2026
Merged

dlyongemallo merged 1 commit into
mainfrom
support_git_lfs

Conversation

@dlyongemallo

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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
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 thread lua/diffview/vcs/file.lua
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 thread lua/diffview/vcs/file.lua
Comment on lines +451 to +452
local git_lfs = require("diffview.vcs.adapters.git.lfs")
local is_lfs = await(self:_lfs_tracked())
Comment thread lua/diffview/vcs/file.lua Outdated
Comment on lines +463 to +465
-- Pointer-view: route through `diffview://` so both sides diff
-- as pointers.
use_diffview_buf = true
@dlyongemallo
dlyongemallo merged commit ac799f1 into main Nov 3, 2026
7 of 8 checks passed
@dlyongemallo
dlyongemallo deleted the support_git_lfs branch November 4, 2026 04:27
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.

2 participants