3 local os = import("os")
4 local filepath = import("path/filepath")
5 local shell = import("micro/shell")
7 function onBufferOpen(buf)
8 if buf.Settings["diffgutter"] and (not buf.Type.Scratch) and (buf.Path ~= "") then
9 -- check that file exists
10 local _, err = os.Stat(buf.AbsPath)
12 local dirName, fileName = filepath.Split(buf.AbsPath)
13 local diffBase, err = shell.ExecCommand("git", "-C", dirName, "show", "HEAD:./" .. fileName)
15 diffBase = buf:Bytes()
17 buf:SetDiffBase(diffBase)