Skip to content

Commit 7e55c3d

Browse files
committed
fix(extra): update git_files picker to not quote paths
Details: - Without extra `core.quotepath=false`, files with multibyte characters are shown differently: in `""` quotes and each byte shown separately. Related to #2188
1 parent cb4420c commit 7e55c3d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lua/mini/extra.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -767,14 +767,14 @@ MiniExtra.pickers.git_files = function(local_opts, opts)
767767
-- Define source
768768
local show = H.pick_get_config().source.show or H.show_with_icons
769769

770-
--stylua: ignore
771-
local command = ({
772-
tracked = { 'git', '-C', path_dir, 'ls-files', '--cached' },
773-
modified = { 'git', '-C', path_dir, 'ls-files', '--modified' },
774-
untracked = { 'git', '-C', path_dir, 'ls-files', '--others' },
775-
ignored = { 'git', '-C', path_dir, 'ls-files', '--others', '--ignored', '--exclude-standard' },
776-
deleted = { 'git', '-C', path_dir, 'ls-files', '--deleted' },
770+
local args = ({
771+
tracked = { '--cached' },
772+
modified = { '--modified' },
773+
untracked = { '--others' },
774+
ignored = { '--others', '--ignored', '--exclude-standard' },
775+
deleted = { '--deleted' },
777776
})[local_opts.scope]
777+
local command = vim.list_extend({ 'git', '-C', path_dir, '-c', 'core.quotepath=false', 'ls-files' }, args)
778778

779779
local name = string.format('Git files (%s)', local_opts.scope)
780780
local default_source = { name = name, cwd = path_dir, show = show }

tests/test_extra.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,9 +1836,8 @@ T['pickers']['git_files()']['works'] = function()
18361836
child.lua_notify('_G.return_item = MiniExtra.pickers.git_files()')
18371837
validate_picker_name('Git files (tracked)')
18381838
child.expect_screenshot()
1839-
eq(get_spawn_log(), {
1840-
{ executable = 'git', options = { args = { '-C', repo_dir, 'ls-files', '--cached' }, cwd = repo_dir } },
1841-
})
1839+
local ref_args = { '-C', repo_dir, '-c', 'core.quotepath=false', 'ls-files', '--cached' }
1840+
eq(get_spawn_log(), { { executable = 'git', options = { args = ref_args, cwd = repo_dir } } })
18421841

18431842
-- Should have proper preview
18441843
type_keys('<Tab>')
@@ -1865,7 +1864,8 @@ T['pickers']['git_files()']['respects `local_opts.path`'] = function()
18651864

18661865
local validate = function(path, ref_cwd)
18671866
pick_git_files({ path = path })
1868-
eq(get_spawn_log()[1].options, { args = { '-C', ref_cwd, 'ls-files', '--cached' }, cwd = ref_cwd })
1867+
local ref_args = { '-C', ref_cwd, '-c', 'core.quotepath=false', 'ls-files', '--cached' }
1868+
eq(get_spawn_log()[1].options, { args = ref_args, cwd = ref_cwd })
18691869
validate_picker_cwd(ref_cwd)
18701870
validate_git_repo_check(dir_path_full)
18711871

@@ -1892,7 +1892,7 @@ T['pickers']['git_files()']['respects `local_opts.scope`'] = function()
18921892

18931893
local validate = function(scope, flags, ref_picker_name)
18941894
pick_git_files({ scope = scope })
1895-
local ref_args = { '-C', test_dir_absolute, 'ls-files' }
1895+
local ref_args = { '-C', test_dir_absolute, '-c', 'core.quotepath=false', 'ls-files' }
18961896
vim.list_extend(ref_args, flags)
18971897
eq(get_spawn_log()[1].options.args, ref_args)
18981898
validate_picker_name(ref_picker_name)

0 commit comments

Comments
 (0)