Skip to content

Commit bd38f10

Browse files
committed
fix(staging): guard against various diff opts breaking output parser
1 parent aaba1af commit bd38f10

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lua/tinygit/commands/stage.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,18 @@ function M.interactiveStaging()
176176
-- GET ALL HUNKS
177177
u.intentToAddUntrackedFiles() -- include untracked files, enables using `--diff-filter=A`
178178
local contextSize = require("tinygit.config").config.stage.contextSize
179+
-- stylua: ignore start
179180
local diffArgs = {
180181
"git",
181-
"-c",
182-
"diff.mnemonicPrefix=false", -- `mnemonicPrefix` creates irregular diff header (#34)
182+
"-c", "diff.mnemonicPrefix=false", -- `mnemonicPrefix` creates irregular diff header (#34)
183+
"-c", "diff.srcPrefix=a/", -- in case use overwrites any of these
184+
"-c", "diff.dstPrefix=b/",
185+
"-c", "diff.noPrefix=false",
183186
"--no-pager",
184187
"diff",
185-
"--no-ext-diff",
186-
"--unified=" .. contextSize,
187-
"--diff-filter=ADMR",
188+
"--no-ext-diff", "--unified=" .. contextSize, "--diff-filter=ADMR",
188189
}
190+
-- stylua: ignore end
189191
-- no trimming, since trailing empty lines can be blank context lines in diff output
190192
local changesDiff = u.syncShellCmd(diffArgs, "notrim")
191193
local changedHunks = getHunksFromDiffOutput(changesDiff, false)

0 commit comments

Comments
 (0)