Skip to content

fix(delete-squashed-branches): preserve default branch and target branch - #1299

Merged
hyperupcall merged 2 commits into
tj:mainfrom
musbabaff:fix/delete-squashed-branches-default-branch
Dec 3, 2026
Merged

hyperupcall merged 2 commits into
tj:mainfrom
musbabaff:fix/delete-squashed-branches-default-branch

Conversation

@musbabaff

Copy link
Copy Markdown
Contributor

Fixes #1292

git-delete-squashed-branches currently iterates over every local branch in refs/heads/ without excluding the default branch. When changes from the default branch (e.g. main, or a custom init.defaultBranch / git-extras.default-branch) have been squash-merged or cherry-picked onto another target branch such as a release branch, running git delete-squashed-branches deletes the default branch.

Changes:

  • Skip $targetBranch, $(git_extra_default_branch), and the standard default branch names (main, master, trunk, svn) in bin/git-delete-squashed-branches, matching bin/git-delete-merged-branches.
  • Guard the git config --get calls in git_extra_default_branch with || true so it remains safe under set -euo pipefail when neither config key is set.
  • Add tests/git-delete-squashed-branches.bats covering default branch preservation, init.defaultBranch, and git-extras.default-branch.

Tested the installed script locally in Git Bash on Windows (reproducing the deletion before the change and verifying all three test cases pass after); relying on CI for Linux/macOS Bats and OpenBSD portability checks.

AI tools assisted with this contribution.

@hyperupcall hyperupcall left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just had one nit.

Comment thread helper/git-extra-utility Resolved
@hyperupcall
hyperupcall merged commit 406acb7 into tj:main Dec 3, 2026
5 checks passed
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.

git-delete-squashed-branches ignores default branch check

3 participants