@@ -28,22 +28,22 @@ local GitAdapter = oop.create_class("GitAdapter", VCSAdapter)
2828GitAdapter .Rev = GitRev
2929
3030--- @return string , string
31- local function pathspec_split (pathspec )
31+ function M . pathspec_split (pathspec )
3232 local magic = pathspec :match (" ^:[/!^]*:?" ) or pathspec :match (" ^:%b()" ) or " "
3333 local pattern = pathspec :sub (1 + # magic , - 1 )
3434 return magic or " " , pattern or " "
3535end
3636
37- local function pathspec_expand (toplevel , cwd , pathspec )
38- local magic , pattern = pathspec_split (pathspec )
37+ function M . pathspec_expand (toplevel , cwd , pathspec )
38+ local magic , pattern = M . pathspec_split (pathspec )
3939 if not utils .path :is_abs (pattern ) then
4040 pattern = utils .path :join (utils .path :relative (cwd , toplevel ), pattern )
4141 end
4242 return magic .. utils .path :convert (pattern )
4343end
4444
45- local function pathspec_modify (pathspec , mods )
46- local magic , pattern = pathspec_split (pathspec )
45+ function M . pathspec_modify (pathspec , mods )
46+ local magic , pattern = M . pathspec_split (pathspec )
4747 return magic .. utils .path :vim_fnamemodify (pattern , mods )
4848end
4949
@@ -57,7 +57,7 @@ function M.get_repo_paths(path_args, cpath)
5757
5858 for _ , path_arg in ipairs (path_args ) do
5959 for _ , path in ipairs (pl :vim_expand (path_arg , false , true )) do
60- local magic , pattern = pathspec_split (path )
60+ local magic , pattern = M . pathspec_split (path )
6161 pattern = pl :readlink (pattern ) or pattern
6262 table.insert (paths , magic .. pattern )
6363 end
@@ -67,7 +67,7 @@ function M.get_repo_paths(path_args, cpath)
6767 cfile = pl :readlink (cfile ) or cfile
6868
6969 for _ , path in ipairs (paths ) do
70- if pathspec_split (path ) == " " then
70+ if M . pathspec_split (path ) == " " then
7171 table.insert (top_indicators , pl :absolute (path , cpath ))
7272 break
7373 end
@@ -158,7 +158,7 @@ function GitAdapter:init(opt)
158158 toplevel = opt .toplevel ,
159159 dir = self :get_dir (opt .toplevel ),
160160 path_args = vim .tbl_map (function (pathspec )
161- return pathspec_expand (opt .toplevel , cwd , pathspec )
161+ return M . pathspec_expand (opt .toplevel , cwd , pathspec )
162162 end , opt .path_args or {}) --[[ @as string[] ]]
163163 }
164164
@@ -304,7 +304,9 @@ local function prepare_fh_options(adapter, log_options, single_file)
304304 o .max_count and { " -n" .. o .max_count } or nil ,
305305 o .diff_merges and { " --diff-merges=" .. o .diff_merges } or nil ,
306306 o .author and { " -E" , " --author=" .. o .author } or nil ,
307- o .grep and { " -E" , " --grep=" .. o .grep } or nil
307+ o .grep and { " -E" , " --grep=" .. o .grep } or nil ,
308+ o .G and { " -E" , " -G" .. o .G } or nil ,
309+ o .S and { " -S" .. o .S , " --pickaxe-regex" } or nil
308310 )
309311 }
310312end
@@ -659,6 +661,8 @@ function GitAdapter:file_history_options(range, paths, args)
659661 { " author" },
660662 { " grep" },
661663 { " base" },
664+ { " G" },
665+ { " S" },
662666 }
663667
664668 --- @type LogOptions
@@ -1462,6 +1466,8 @@ GitAdapter.flags = {
14621466 },
14631467 { " =a" , " --author=" , " List only commits from a given author" , prompt_label = " (Extended regular expression)" },
14641468 { " =g" , " --grep=" , " Filter commit messages" , prompt_label = " (Extended regular expression)" },
1469+ { " =G" , " -G" , " Search changes" , prompt_label = " (Extended regular expression)" },
1470+ { " =S" , " -S" , " Search occurrences" , prompt_label = " (Extended regular expression)" },
14651471 {
14661472 " --" , " --" , " Limit to files" ,
14671473 key = " path_args" ,
@@ -1672,6 +1678,8 @@ function GitAdapter:init_completion()
16721678 })
16731679 self .comp .file_history :put ({ " --author" }, {})
16741680 self .comp .file_history :put ({ " --grep" }, {})
1681+ self .comp .file_history :put ({ " -G" }, {})
1682+ self .comp .file_history :put ({ " -S" }, {})
16751683end
16761684
16771685M .GitAdapter = GitAdapter
0 commit comments