Skip to content

fix(push): avoid fatal errors when pushing a branch with no own commits - #83

Merged
maxbolgarin merged 1 commit into
mainfrom
claude/intelligent-mayer-o8y3u9
Oct 13, 2026
Merged

maxbolgarin merged 1 commit into
mainfrom
claude/intelligent-mayer-o8y3u9

Conversation

@maxbolgarin

Copy link
Copy Markdown
Owner

Summary

  • get_push_list found the base commit by running diff -u on the first-parent histories of the current and main branches. When the two are identical (a new branch with no commits of its own, e.g. develop just created from main), diff prints nothing. The code then fell back to origin/<main>..HEAD, which printed fatal: ambiguous argument ... unknown revision twice when that ref isn't on the remote.
  • The fix falls back to git merge-base and only uses origin/<main> when that ref actually exists. Otherwise it lists the branch's history, the same as the existing new-repo case.
  • This fixes gitb push, gitb commit fp, and the branch-switch summary, since all three call get_push_list.

Linked issue

None. Reported directly by the user, with screenshots of gitb p and gitb c fp.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Test plan

  • Added 2 BATS tests in tests/test_repository_helpers.bats. The empty-branch test fails without the fix and passes with it.
  • tests/test_repository_helpers.bats and tests/test_git_operations.bats pass (58/58)
  • tests/bash32_compat_check.sh passes

Compatibility

  • Bash 3.2 compatible (no new constructs; only git merge-base and git rev-parse --verify --quiet)

Checklist

  • Commit messages follow Conventional Commits
  • Variables in git invocations are quoted
  • BATS tests added

🤖 Generated with Claude Code

https://claude.ai/code/session_01CJJ6pKYtogfzy6MJFMpYgo


Generated by Claude Code

get_push_list found the base commit by diffing the first-parent histories
of the current and main branches. When both are identical (a fresh branch
with no commits of its own) diff prints nothing, so it fell back to
origin/<main>..HEAD, which fails loudly when the main branch isn't on the
remote. Fall back to git merge-base, and only use origin/<main> when that
ref actually exists.

Affects gitb push, gitb commit fp and the branch-switch summary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CJJ6pKYtogfzy6MJFMpYgo
@maxbolgarin
maxbolgarin merged commit d8ff3f8 into main Oct 13, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 5.3.1 🎉

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