Skip to content

choose_merge_request crashes on detached HEAD #555

@seflue

Description

@seflue

Prerequsities

  • I'm on the latest version of the plugin
  • I've installed the required dependencies
  • I've run :h gitlab.nvim.troubleshooting and followed the steps there

Setup Configuration and Environment

Default configuration; no environment variables relevant to this path.

Bug Description

choose_merge_request() crashes when the working tree is in detached
HEAD (or in a fresh repo without commits):

.../lua/gitlab/git.lua:112: attempt to concatenate local 'err' (a nil value)
stack traceback:
  .../lua/gitlab/git.lua:112: in function 'get_current_branch'
  .../lua/gitlab/actions/merge_requests.lua:33: in function 'cb'

git branch --show-current returns an empty string with exit code 0
in that case, so err is nil and the error branch in git.lua:112
concatenates nil into the notify message.

The only caller of get_current_branch() in this flow is
merge_requests.lua:33, which uses the return value to skip a
clean-tree check and a no-op switch_branch when the user is already
on the source branch, so detached HEAD has no semantic meaning here
beyond the crash itself.

Happy to open a PR.

Reproduction Steps

  1. Check out an arbitrary commit in detached HEAD mode
  2. In Neovim: :lua require("gitlab").choose_merge_request()
  3. Pick any MR → crash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions