-
-
Notifications
You must be signed in to change notification settings - Fork 821
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
Encountered an error when using git_command
in git_bcommits
#2517
Comments
I can reproduce this. I dug around a little bit while I don't really have a solution, my instinct is telling me that that command is not very well suited for passing the output through pipes. At least not with how telescope currently works. I played around with this bit of code. If you do as well, you should see that, for you command, after the first stdout chunk, each subsequent chunk appears to start with a new line. The telescope code doesn't handle that well. Try it with the original command, the new line comes after the chunk is done. Maybe the telescope code should handle this better, but also maybe git is being weird. the codelocal uv = vim.loop
local stdin = uv.new_pipe()
local stdout = uv.new_pipe()
local stderr = uv.new_pipe()
local handle, pid = uv.spawn("git", {
args = {
"log",
-- "--pretty=oneline",
-- "--abbrev-commit",
"--date=format:%y/%m/%d",
"--pretty=format:%h %ad %s",
"--follow",
"/tmp/testing/dotfile/nvim/.config/nvim/lua/plugins/telescope.lua",
},
stdio = {
stdin,
stdout,
stderr,
},
}, function(code, signal) -- on exit
print("exit code", code)
print("exit signal", signal)
end)
print("process opened", handle, pid)
stdout:read_start(function(err, data)
assert(not err, err)
if data then
vim.print("stdout chunk", data)
else
vim.print("stdout end")
end
end) |
Thanks for your instinct, I find a workround to solve this issue. I create a bash script named This is my script: #!/usr/bin/env bash
# $1 is the file path from Telescope
git log --date="format:%y/%m/%d" --pretty="format:%C(auto) %h %ad %s" --follow $1 >/tmp/gitlog && cat /tmp/gitlog And this is my Telescope config config = function()
local bufopts = { noremap = true, silent = true }
local builtin = require("telescope.builtin")
vim.keymap.set("n", "gb", function()
builtin.git_bcommits({
git_command = { "/location/of/gitlog.sh" },
})
end, bufopts)
vim.keymap.set("n", "gj", builtin.git_bcommits, bufopts)
require("telescope").setup({})
end, |
@jamestrew Do you think it's necessary to keep this issue open and let's work through it to solve the problem once and for all, or do we just stop here, there's already a workround anyway, after all not all bugs have to be fixed and it's not necessarily a Telescope's bug |
I think it's ok to leave it open. This might be something worth looking into deeper. |
I tried your workaound, but I still get an empty window. However if I replace what’s inside of the git log --follow $1 >/tmp/gitlog && cat /tmp/gitlog then I do get the result of git log in my telescope popup … EDIT: If I just add an ¯\_(ツ)_/¯ So the workaround becomes git log --date="format:%y/%m/%d" --pretty="format:%C(auto) %h %ad %s" --follow $1 \
>/tmp/gitlog \
&& echo "" >> /tmp/gitlog \
&& cat /tmp/gitlog |
Description
In my use case, I use customized
git_command
ingit_bcommits
, and meet errorBut if I use default command, it's ok
My customized command:
Default command in Telescope
I think maybe my customized command missed something needed, but I can not find the difference between the results of these two command
PS. This issue can be reliably reproduced only on some files. If you cannot reproduce it in your projects or files, please try this file https://github.com/keaising/dotfile/blob/master/nvim/.config/nvim/lua/plugins/telescope.lua , the issue can be reliably reproduced on it.
Neovim version
Operating system and version
ArchLinux, latest
Telescope version / branch / rev
master branch
checkhealth telescope
Steps to reproduce
git clone git@github.com:keaising/dotfile.git
minimal.lua
content intominimal.lua
in dotfile foldernvim -u minimal.lua nvim/.config/nvim/lua/plugins/telescope.lua
lazy
install all plugins neededgb
can meet the errorgj
will not meet the errorExpected behavior
No error
Actual behavior
Minimal config
The text was updated successfully, but these errors were encountered: