Skip to content

Fix git-drive pull crash when the branch isn't on the origin (1.10.1) - #15

Merged
gmpassos merged 2 commits into
masterfrom
fix/git-pull-fetch-head
Jul 2, 2026
Merged

Fix git-drive pull crash when the branch isn't on the origin (1.10.1)#15
gmpassos merged 2 commits into
masterfrom
fix/git-pull-fetch-head

Conversation

@gmpassos

@gmpassos gmpassos commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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 merge

Root 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:

  • Pull now no-ops when the current branch does not exist on the origin (there's nothing to pull) instead of erroring.
  • When the branch does exist, pull fetches it by name (git fetch origin <branch>) and fast-forwards to FETCH_HEAD — which additionally fixes pulls on shallow/single-branch clones whose origin/<branch> remote-tracking ref is absent.
  • GitCli.fetch gains an optional branch; adds GitCli.remoteHasBranch. Applied in both GitSynchronizer.apply and GitMountedDrive.applyRemote.

Test plan

  • dart analyze + dart format --set-exit-if-changed . — clean.
  • New regression tests: (1) pull is a clean no-op when the branch isn't on the origin (the exact reported scenario); (2) fetch-by-name + FETCH_HEAD works when origin/<branch> tracking ref is absent (shallow single-branch clone).
  • Full suite green (236 tests).

🤖 Generated with Claude Code

gmpassos and others added 2 commits July 2, 2026 01:26
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>
@gmpassos gmpassos changed the title Fix git-drive pull when origin/<branch> tracking ref is absent (1.10.1) Fix git-drive pull crash when the branch isn't on the origin (1.10.1) Jul 2, 2026
@gmpassos
gmpassos merged commit caad1d6 into master Jul 2, 2026
2 checks passed
@gmpassos
gmpassos deleted the fix/git-pull-fetch-head branch July 2, 2026 04:32
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.

1 participant