sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.6k stars 101 forks source link

[Bug] attempt to index a nil value #414

Closed emmanueltouzery closed 10 months ago

emmanueltouzery commented 10 months ago

Description

I got this crash when using diffview, I'm using 7e5a85c186027cab1e825d018f07c350177077fc. I don't think I did anything special....

Expected behavior

No response

Actual behavior

E5108: Error executing lua vim/_editor.lua:0: nvim_exec2(): Vim:Error executing Lua callback: ...art/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:1333: attempt to index a nil value
stack traceback:
    ...art/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:1333: in function 'symmetric_diff_revs'
    ...art/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:1382: in function 'parse_revs'
    ...art/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:1250: in function 'diffview_options'
    ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:43: in function 'diffview_open'
    ...te/pack/packer/start/diffview.nvim/lua/diffview/init.lua:130: in function 'open'
    ...site/pack/packer/start/diffview.nvim/plugin/diffview.lua:24: in function <...site/pack/packer/start/diffview.nvim/plugin/diffview.lua:23>
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function 'cmd'
    ...e/emmanuel/.config-nvim7me/nvim/lua/leader_shortcuts.lua:308: in function 'key_func'
    ...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:352: in function 'execute_keymap'
    [string ":lua"]:1: in main chunk
stack traceback:
    [C]: in function 'nvim_exec2'
    vim/_editor.lua: in function 'cmd'
    ...e/emmanuel/.config-nvim7me/nvim/lua/leader_shortcuts.lua:308: in function 'key_func'
    ...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:352: in function 'execute_keymap'
    [string ":lua"]:1: in main chunk

Steps to reproduce

unfortunately i have no idea how to reproduce this issue :(

Health check

Output of :checkhealth diffview ``` ============================================================================== diffview: require("diffview.health").check() Checking plugin dependencies ~ - OK nvim-web-devicons installed. Checking VCS tools ~ - The plugin requires at least one of the supported VCS tools to be valid. - OK Git found. - OK Git is up-to-date. (2.41.0) - WARNING Configured `hg_cmd` is not executable: 'hg' ```

Log info

Relevant info from :DiffviewLog ``` [INFO 2023-08-28 08:43:20.769 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-08-28 08:43:20.875 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 0 files successfully (35.088 ms) [INFO 2023-08-28 08:43:24.582 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen origin/develop... [ERROR 2023-08-28 08:43:24.669 +0200] ...ck/packer/start/diffview.nvim/lua/diffview/multi_job.lua:143: Inbalance in diff data! [ERROR 2023-08-28 08:43:24.669 +0200] ...ck/packer/start/diffview.nvim/lua/diffview/multi_job.lua:146: [job-info] Exit code: 0 [ERROR 2023-08-28 08:43:24.669 +0200] ...ck/packer/start/diffview.nvim/lua/diffview/multi_job.lua:146: [cmd] git 'diff' '--ignore-submodules' '--name-status' '848f29961783c1542c9a535057a1e8afb132a8f6..86876920d8fa001c38fc9faef495cf17eb796f61' '--' [ERROR 2023-08-28 08:43:24.669 +0200] ...ck/packer/start/diffview.nvim/lua/diffview/multi_job.lua:146: [cwd] /home/emmanuel/projects/flatman [ERROR 2023-08-28 08:43:24.669 +0200] ...ck/packer/start/diffview.nvim/lua/diffview/multi_job.lua:149: (1/2) Retrying failed jobs... [INFO 2023-08-28 08:43:24.676 +0200] ...ck/packer/start/diffview.nvim/lua/diffview/multi_job.lua:158: Retry was successful! [INFO 2023-08-28 08:43:24.705 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 42 files successfully (51.021 ms) [INFO 2023-08-28 08:43:45.867 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:74: [command call] :DiffviewFileHistory /home/emmanuel/projects/flatman [INFO 2023-08-28 08:43:45.987 +0200] ...art/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:880: [FileHistory] Updating with options: { flags = { "-n256", "--diff-merges=first-parent" }, path_args = { "/home/emmanuel/projects/flatman" } } [WARN 2023-08-28 08:43:46.046 +0200] ...art/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:1185: [GitAdapter:parse_fh_data()] Encountered commit with no file data: { author = "Jernej Logar", left_hash = "3b8ec6291b0f9e4c2e60268213b65f389bf24f94", merge_hash = "090564313ccb1354e2968fea1ff2e9f7d52156db", namestat = {}, numstat = {}, ref_names = "", reflog_selector = "", rel_date = "5 days ago", right_hash = "6bb7ca511422884f559ebb8efc3c4221d01b311e", subject = "Merge branch 'master' into develop", time = 1692786545, time_offset = "+0200", valid = true } [INFO 2023-08-28 08:43:46.541 +0200] ...diffview/scene/views/file_history/file_history_panel.lua:248: [FileHistory] Completed update for 255 entries successfully (554.180 ms). [INFO 2023-08-28 08:44:00.827 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:74: [command call] :DiffviewFileHistory /home/emmanuel/projects/flatman [INFO 2023-08-28 08:44:00.910 +0200] ...art/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:880: [FileHistory] Updating with options: { flags = { "-n256", "--diff-merges=first-parent" }, path_args = { "/home/emmanuel/projects/flatman" } } [WARN 2023-08-28 08:44:01.038 +0200] ...art/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:1185: [GitAdapter:parse_fh_data()] Encountered commit with no file data: { author = "Jernej Logar", left_hash = "3b8ec6291b0f9e4c2e60268213b65f389bf24f94", merge_hash = "090564313ccb1354e2968fea1ff2e9f7d52156db", namestat = {}, numstat = {}, ref_names = "", reflog_selector = "", rel_date = "5 days ago", right_hash = "6bb7ca511422884f559ebb8efc3c4221d01b311e", subject = "Merge branch 'master' into develop", time = 1692786545, time_offset = "+0200", valid = true } [INFO 2023-08-28 08:44:01.459 +0200] ...diffview/scene/views/file_history/file_history_panel.lua:248: [FileHistory] Completed update for 255 entries successfully (549.656 ms). [INFO 2023-08-28 08:46:07.099 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-08-28 08:46:07.250 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (60.638 ms) [INFO 2023-08-28 08:46:07.910 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (69.505 ms) [INFO 2023-08-28 08:46:08.218 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (51.846 ms) [INFO 2023-08-28 08:57:04.343 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen origin/develop... [INFO 2023-08-28 08:57:04.492 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 42 files successfully (53.444 ms) [INFO 2023-08-28 09:13:25.049 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-08-28 09:13:25.261 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (78.076 ms) [INFO 2023-08-28 09:14:36.794 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-08-28 09:14:36.959 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (62.000 ms) [INFO 2023-08-28 09:15:25.562 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-08-28 09:15:25.743 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (61.759 ms) [INFO 2023-08-28 09:16:06.058 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-08-28 09:16:06.251 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (62.773 ms) [INFO 2023-08-28 09:16:33.155 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (83.544 ms) [INFO 2023-08-28 09:16:33.305 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 1 files successfully (108.265 ms) [INFO 2023-08-28 09:16:56.535 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen origin/develop... [INFO 2023-08-28 09:18:02.499 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [INFO 2023-08-28 09:18:02.690 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 0 files successfully (48.036 ms) [INFO 2023-08-28 09:18:06.678 +0200] ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen origin/develop... [INFO 2023-08-28 09:18:06.931 +0200] ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:483: [DiffView] Completed update for 42 files successfully (93.885 ms) ```

Neovim version

NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

Linux 6.4.12-200.fc38.x86_64 x86_64 GNU/Linux

Minimal config

No response

benjaminchristie commented 10 months ago

The naive solution to this would be to return a nonzero error code from GitAdapter.exec_sync if stdout is nil, but there is some other underlying issue here.

sindrets commented 10 months ago

No one here is able to reproduce this reliably, right? The underlying issue is something I've been aware of for a while. Git jobs sometimes fail silently, with exit code 0 and no stdout. There's no naive solution to this, because there are plenty of Git commands that aren't supposed to have any stdout. We can't just force fail every job that doesn't give stdout. But we do have fail conditions that we can set on a per job basis. So I could enable that for this specific job.

@benjaminchristie did you get this same error from the same location in code?

benjaminchristie commented 10 months ago

I did once on db97e66, but I was unable to repeat it.

sindrets commented 10 months ago

The rev arg parsing should be more resilient now, but do let me know if it's still a problem.