Skip to content

fixing the call to vim.fn.system #1550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/nvim-tree/git/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function M.get_toplevel(cwd)
local ps = log.profile_start("git toplevel %s", cwd)
log.line("git", cmd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd is unused.

Please replace cmd with { "git", "-C", vim.fn.shellescape(cwd), "rev-parse", "--show-toplevel" }, log it and and pass it to vim.fn.system(


local toplevel = vim.fn.system(cmd)
local toplevel = vim.fn.system { "git", "-C", vim.fn.shellescape(cwd), "rev-parse", "--show-toplevel" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails:

[2022-08-27 13:15:55] [profile] START git toplevel /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon
[2022-08-27 13:15:55] [git] git -C '/home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon' rev-parse --show-toplevel
fatal: cannot change to ''/home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon'': No such file or directory
[2022-08-27 13:15:55] [profile] END   git toplevel /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon  2ms

master:

[2022-08-27 13:15:28] [profile] START git toplevel /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon
[2022-08-27 13:15:28] [git] git -C '/home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon' rev-parse --show-toplevel
/home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon
[2022-08-27 13:15:28] [profile] END   git toplevel /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon  8ms
[2022-08-27 13:15:28] [profile] START git untracked /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon
[2022-08-27 13:15:28] [git] git -C /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon config status.showUntrackedFiles
[2022-08-27 13:15:28] [profile] END   git untracked /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon  7ms
[2022-08-27 13:15:28] [profile] START git job /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon nil
[2022-08-27 13:15:28] [git] running job with timeout 400ms
[2022-08-27 13:15:28] [git] git --no-optional-locks status --porcelain=v1 --ignored=matching -u
!! doc/tags
[2022-08-27 13:15:28] [git] done
[2022-08-27 13:15:28] [profile] END   git job /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon nil  4ms
[2022-08-27 13:15:28] [git] job success    /home/alex/.local/share/nvim/vundle/nvim-tree.lua.Xyhlon nil
log = {
      enable = true,
      truncate = true,
      types = {
        git = true,
        profile = true,
      },
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you remove vim.fn.shellescape from cwd in the cmd everything works without the fatal error message


log.raw("git", toplevel)
log.profile_end(ps, "git toplevel %s", cwd)
Expand Down