Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dolt push may be overly aggressive in its fast-forward check. #7448

Closed
reltuk opened this issue Feb 1, 2024 · 1 comment
Closed

dolt push may be overly aggressive in its fast-forward check. #7448

reltuk opened this issue Feb 1, 2024 · 1 comment
Assignees
Labels
bug Something isn't working cli version control

Comments

@reltuk
Copy link
Contributor

reltuk commented Feb 1, 2024

Dolt push currently runs a fast-forward branch check against the local tracking reference to the remote branch before it goes ahead with the push attempt. This means that if the local tracking reference is stale, you can get a failure. This can really come up if the remote branch has been deleted.

For example, consider the following:

First, make a remote with a main and an alt branch, with your repo tracking both:

mkdir repo
cd repo
dolt init
dolt remote add origin file://../remote
dolt push origin main:main
dolt checkout -b alt
dolt commit -m new --allow-empty
dolt push origin alt:alt

Then, merge the alt branch to main, push it to main, and delete the alt branch from the remote:

cd ..
dolt clone file://remote cloned
cd cloned
dolt merge origin/alt
dolt push origin main:main
dolt push origin :alt

Then go back to the original repo, create a new branch alt HEAD off of main, and attempt to push that to the remote alt:

cd ../repo
dolt checkout main
dolt checkout -B alt
dolt commit -m another --allow-empty
dolt push origin alt:alt

At that point, you will get a rejected push:

- Uploading...To file:///Users/aaronson/DoltPushBug/remote
 ! [rejected]            alt -> alt (non-fast-forward)
error: failed to push some refs to 'file:///Users/aaronson/DoltPushBug/remote'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'dolt pull ...') before pushing again.

Ways to fix include:

dolt push -f alt:alt

or running

dolt fetch -p origin

before you push.

It's not clear to me to what degree we should be using the local tracking branch state for this fast-forward check.

@timsehn timsehn added bug Something isn't working cli version control labels Feb 1, 2024
@macneale4 macneale4 self-assigned this Feb 1, 2024
macneale4 added a commit that referenced this issue Feb 2, 2024
@reltuk
Copy link
Contributor Author

reltuk commented Feb 2, 2024

Fixed in #7450

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli version control
Projects
None yet
Development

No branches or pull requests

3 participants