Skip to content

fix(git): handle detached HEAD silently#557

Merged
jakubbortlik merged 1 commit intoharrisoncramer:developfrom
seflue:fix/get-current-branch-detached-head
May 5, 2026
Merged

fix(git): handle detached HEAD silently#557
jakubbortlik merged 1 commit intoharrisoncramer:developfrom
seflue:fix/get-current-branch-detached-head

Conversation

@seflue
Copy link
Copy Markdown
Contributor

@seflue seflue commented May 5, 2026

Closes #555.

git branch --show-current returns an empty string with exit code 0 when HEAD is detached or the repo has no commits. That's a valid state, not an error. The old code routed it through the error branch anyway, so the operation was cancelled with an error message instead of proceeding.

The fix splits the two cases. In detached HEAD, the picker now proceeds with the check-out (the caller in merge_requests.lua:33 already handles nil). Real git failures still notify ERROR.

Allow reviewing a merge request from detached HEAD.
@seflue seflue force-pushed the fix/get-current-branch-detached-head branch from 3412d88 to 7439c41 Compare May 5, 2026 01:07
Comment thread lua/gitlab/git.lua
@jakubbortlik jakubbortlik merged commit 286fdb5 into harrisoncramer:develop May 5, 2026
4 checks passed
@jakubbortlik
Copy link
Copy Markdown
Collaborator

Hi @seflue, thanks for the contribution.

@seflue seflue deleted the fix/get-current-branch-detached-head branch May 5, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

choose_merge_request crashes on detached HEAD

2 participants