Skip to content

fix(branch): pass HEAD to --merged when deleting merged branches - #81

Merged
maxbolgarin merged 1 commit into
mainfrom
claude/exciting-hawking-86137k
Sep 30, 2026
Merged

maxbolgarin merged 1 commit into
mainfrom
claude/exciting-hawking-86137k

Conversation

@maxbolgarin

Copy link
Copy Markdown
Owner

Summary

  • gitb branch delete → "Delete these merged branches? y" failed with fatal: malformed object name --format=%(refname:short) and deleted nothing. git branch --merged takes an optional commit argument, so git read the following --format=... as that commit. The fix passes HEAD explicitly: git branch --merged HEAD --format='%(refname:short)'.
  • Added BATS regression tests: one checks that the merged-branch listing works, and a static check fails if --merged/--no-merged is ever followed directly by another flag in scripts/.

Linked issue

None. The bug was reported directly with a screenshot of the failing prompt.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor (no behavior change)
  • Documentation only

Test plan

  • bats tests/test_branch_operations.bats: the new static check fails on the old code and passes with the fix. The pre-existing tests 4, 5 and 14 fail either way because the test container has no column binary.
  • shellcheck scripts/*.sh install.sh: shellcheck isn't installed in the test environment
  • Built bundle runs: bash dist/build.sh ./scripts/gitb.sh ./dist/gitb dev && bash ./dist/gitb --version
  • Reproduced the failure and verified the fix on git 2.43:
$ git branch --merged --format='%(refname:short)'
fatal: malformed object name --format=%(refname:short)
$ git branch --merged HEAD --format='%(refname:short)'
main

Compatibility

  • Works on macOS (BSD userland)
  • Works on Linux (GNU userland)
  • Bash 3.2 compatible

Checklist

  • Commit messages follow Conventional Commits
  • Variables in git invocations are quoted
  • No new xargs -r / GNU-only patterns
  • BATS tests added for non-trivial behavior changes
  • README / CONTRIBUTING updated if user-facing behavior changed (not needed)

🤖 Generated with Claude Code

https://claude.ai/code/session_01N7bXuSKAQZEE7BsHZdjQ21


Generated by Claude Code

`git branch --merged --format=...` fails with "malformed object name
--format=%(refname:short)" because --merged takes an optional commit and
git consumes the next argument as it. Deleting merged branches from
`gitb branch delete` therefore did nothing. Pass HEAD explicitly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N7bXuSKAQZEE7BsHZdjQ21
@maxbolgarin
maxbolgarin merged commit 2cdaf58 into main Sep 30, 2026
8 checks passed
@maxbolgarin
maxbolgarin deleted the claude/exciting-hawking-86137k branch September 30, 2026 12:36
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 5.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants