Fix git-drive pull crash when the branch isn't on the origin (1.10.1) - #15
Merged
Conversation
The pull path ran a bare `git fetch origin` then `git merge --ff-only origin/<current-branch>`, which fails with "not something we can merge" when that remote-tracking ref doesn't exist — e.g. a shallow/single-branch clone, or a branch checked out by name. Pull now fetches the current branch explicitly (`git fetch origin <branch>`) and fast-forwards to FETCH_HEAD, in both GitSynchronizer.apply and GitMountedDrive.applyRemote. GitCli.fetch gains an optional `branch` argument. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Root cause of the reported crash (`git merge --ff-only origin/<branch> - not something we can merge`): the endpoint was on a branch it had never pushed, so the branch doesn't exist on the origin. Pull now no-ops when the branch is absent from the origin (nothing to pull). When it is present, pull fetches it by name and fast-forwards to FETCH_HEAD, which also fixes shallow/single-branch clones whose origin/<branch> tracking ref is absent. GitCli.fetch gains an optional `branch`; adds GitCli.remoteHasBranch. Applied in both GitSynchronizer.apply and GitMountedDrive.applyRemote. Regression tests cover the no-op (branch not on origin) and the fetch-by-name cases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes git-drive pull crashing with:
ProviderException(provider_error): git merge --ff-only origin/<branch> failed (1): merge: origin/<branch> - not something we can mergeRoot cause: the endpoint was on a branch it had never pushed to the origin, so that branch doesn't exist there. The pull path unconditionally ran
git merge --ff-only origin/<current-branch>, which fails when the ref is absent.Fix:
git fetch origin <branch>) and fast-forwards toFETCH_HEAD— which additionally fixes pulls on shallow/single-branch clones whoseorigin/<branch>remote-tracking ref is absent.GitCli.fetchgains an optionalbranch; addsGitCli.remoteHasBranch. Applied in bothGitSynchronizer.applyandGitMountedDrive.applyRemote.Test plan
dart analyze+dart format --set-exit-if-changed .— clean.FETCH_HEADworks whenorigin/<branch>tracking ref is absent (shallow single-branch clone).🤖 Generated with Claude Code