@@ -31,6 +31,39 @@ local split_query_from_author = function(query)
31
31
return prompt , author
32
32
end
33
33
34
+ --- @param command table
35
+ --- @param git_flags_ix number | nil
36
+ --- @param git_diff_flags_ix number | nil
37
+ --- @return table Command with configured git diff flags
38
+ local git_diff_command = function (command , git_flags_ix , git_diff_flags_ix )
39
+ git_flags_ix = git_flags_ix or 2
40
+ git_diff_flags_ix = git_diff_flags_ix or 3
41
+
42
+ local git_diff_flags = config .git_diff_flags ()
43
+ local git_flags = config .git_flags ()
44
+
45
+ if git_flags_ix > git_diff_flags_ix then
46
+ vim .notify (
47
+ " git_flags must be inserted before git_diff_flags" ,
48
+ vim .log .levels .ERROR
49
+ )
50
+ end
51
+
52
+ if git_diff_flags ~= nil and # git_diff_flags > 0 then
53
+ for i , flag in ipairs (git_diff_flags ) do
54
+ table.insert (command , git_diff_flags_ix + i - 1 , flag )
55
+ end
56
+ end
57
+
58
+ if git_flags ~= nil and # git_flags > 0 then
59
+ for i , flag in ipairs (git_flags ) do
60
+ table.insert (command , git_flags_ix + i - 1 , flag )
61
+ end
62
+ end
63
+
64
+ return command
65
+ end
66
+
34
67
local git_log_entry_maker = function (entry )
35
68
-- dce3b0743 2022-09-09 author _ message
36
69
-- FIXME: will break if author contains _
@@ -183,7 +216,7 @@ M.git_diff_previewer_file = function(bufnr)
183
216
local commit_hash = entry .opts .commit_hash
184
217
185
218
local prev_commit = string.format (" %s~" , commit_hash )
186
- return {
219
+ return git_diff_command ( {
187
220
" git" ,
188
221
" diff" ,
189
222
prev_commit
@@ -192,7 +225,7 @@ M.git_diff_previewer_file = function(bufnr)
192
225
commit_hash
193
226
.. " :"
194
227
.. determine_historic_file_name (commit_hash , bufnr ),
195
- }
228
+ })
196
229
end ,
197
230
})
198
231
end
@@ -250,5 +283,6 @@ M.current_branch = function()
250
283
end
251
284
252
285
M .determine_historic_file_name = determine_historic_file_name
286
+ M .git_diff_command = git_diff_command
253
287
254
288
return M
0 commit comments