Skip to content

fix(picker.git): handle unnamed buffers in git log pickers - #2956

Open
jiminu wants to merge 1 commit into
folke:mainfrom
jiminu:fix/git-log-unnamed-buffer
Open

jiminu wants to merge 1 commit into
folke:mainfrom
jiminu:fix/git-log-unnamed-buffer

Conversation

@jiminu

@jiminu jiminu commented Sep 13, 2026

Copy link
Copy Markdown

Description

git_log_file and git_log_line currently pass the empty string returned by nvim_buf_get_name() for unnamed buffers to Git. Since an empty string is truthy in Lua, both the rename-detection command and the main log command run with an empty pathspec and report command failures.

This reads the current buffer name once for file-scoped log pickers and returns an empty finder with a clear warning when the buffer has no file. Repository-wide git_log behavior is unchanged.

This fixes the validation in the picker source so callers do not need to guard every keymap, as proposed in #2599.

Related Issue(s)

Related to #2599.

Testing

  • Reproduced both failing Git commands with git_log_file on an unnamed buffer before the change
  • Verified git_log_file and git_log_line on unnamed and nofile buffers show Current buffer has no file without a Git command failure
  • Verified both pickers still run for a tracked file (README.md)
  • Ran git diff --check

@github-actions github-actions Bot added picker size/s Small PR (<10 lines changed) labels Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

picker size/s Small PR (<10 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant