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

Cannot push to new branch on remote #950

Closed
oli-obk opened this issue Sep 28, 2022 · 18 comments
Closed

Cannot push to new branch on remote #950

oli-obk opened this issue Sep 28, 2022 · 18 comments

Comments

@oli-obk
Copy link

oli-obk commented Sep 28, 2022

I am trying to push changes from my partial fork to the main fork and then open a PR against the main fork. I am getting odd git errors I've never seen before:

ubuntu@ip-172-31-35-201 ~/c/miri (josh)> git push -u josh-oli josh
Enumerating objects: 40345, done.
Counting objects: 100% (40345/40345), done.
Delta compression using up to 96 threads
Compressing objects: 100% (13648/13648), done.
Writing objects: 100% (40345/40345), 9.54 MiB | 6.07 MiB/s, done.
Total 40345 (delta 28201), reused 37473 (delta 25565)
remote: Resolving deltas: 100% (28201/28201), done.
remote: josh-proxy
remote: response from upstream:
remote: Reference "refs/heads/josh" does not exist on remote.
remote: If you want to create it, pass "-o base=<basebranch>" or "-o base=path/to/ref"
remote: to specify a base branch/reference.
remote: 
remote: 
remote: 
remote: error: hook declined to update refs/heads/josh
To http://localhost:8000/oli-obk/rust.git
 ! [remote rejected]   josh -> josh (hook declined)

Is there a better way to sync changes back?

@oli-obk
Copy link
Author

oli-obk commented Sep 28, 2022

I have tried creating a branch and pushing to that, but no matter which commit I place that branch on, I always get

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.

no matter which commit I place the branch on the remote at. Is there a specific commit I need to point it at?

@LMG
Copy link
Collaborator

LMG commented Sep 28, 2022

Hi @oli-obk ,

what the first message was trying to tell you is that josh doesn't know where to put this new branch you're pushing. So you should tell it, by providing a "base", another branch from which yours was derived. You can do that with

git push origin your-branch -o base=master

for example, if you branched off of master.

Now that you've created your remote branch, you might want to delete it and try this way instead.

@christian-schilling
Copy link
Member

Hi @oli-obk,
When creating a new branch via a partial repo, you need to pass the base (target) branch when doing the push. It says so in the error message.
So if your work is based on refs/heads/master and you want to create a PR to merge into refs/heads/master you need to push like this:
git push -o base=refs/heads/master origin local_branch_name:refs/heads/remote_branch_name

@oli-obk
Copy link
Author

oli-obk commented Sep 28, 2022

Passing this flag seems to make no difference at all. I keep getting exactly the same error.

I have tried using:

  • commit id of latest main repo master (further ahead than partial repo)
  • commit id of original sync in main repo
  • commit id of original sync in partial repo

None of these worked or changed the output.

@oli-obk
Copy link
Author

oli-obk commented Sep 28, 2022

I may just have screwed up the remotes -.- Will get back to you

@LMG
Copy link
Collaborator

LMG commented Sep 28, 2022

Did you delete the branch you created on the remote, before re-trying with -o base ?

@oli-obk
Copy link
Author

oli-obk commented Sep 28, 2022

yes, I tried that, too. I think my main issue may be selecting the right base. I keep getting failures if I use -o base=commit_hash. The latest one is

remote: fatal: bad object refs/namespaces/request_f1a6763e-8839-4557-8f16-9b77c1ac5b76/push_options

I accidentally used -o commit_hash (not the lack of base=) and now it's busy eating CPU time, so I'll let that run for a while.

@LMG
Copy link
Collaborator

LMG commented Sep 28, 2022

no, -o commit_hash won't do anything, and -o base takes a ref, not a commit sha. Josh basically searches for the point where you branched off of using this ref. It won't work with a commit. -o base=master is a shorthand which gets replaced by josh with the fully qualified ref, refs/heads/master

@LMG
Copy link
Collaborator

LMG commented Sep 28, 2022

In other words, if you created your branch while having master checked out the correct base is master.

@christian-schilling
Copy link
Member

Like @LMG said, the base parameter only supports refs, not commit hashes. I think we can add that, although I don't understand why you can't specify a ref instead. Are you trying to somehow fix the issue of commit duplication you are mentioning in rust-lang/miri#2569 ?

We'll investigate what caused the CPU time eating with the erroneous parameter...

@oli-obk
Copy link
Author

oli-obk commented Sep 28, 2022

I'm trying with base=master now. Took a minute or two, then I got

remote: josh-proxy
remote: response from upstream:
remote: rejecting merge with 2 parents:
remote: "Merge remote-tracking branch 'upstream/master' into josh"

The reason base=master didn't work before... is that the master branch on my personal fork was outdated 5 years, but I did the partial repo pull from the master branch on the official repo 🤦

@oli-obk
Copy link
Author

oli-obk commented Sep 28, 2022

googling reveals nothing on this error if it comes from github.

If it comes from josh, maybe it's because of the way I did the partial repo pull:

  1. we did a git subtree add on the rust repo
  2. I added a partial repo (pointing to the rust repo's directory where the subtree lives) to the miri repo
  3. I checked out the master branch from that repo
  4. I merged that master branch into the miri master branch

so now there are two unrelated histories that got merged inside the miri repo.

Then I tried to push the result of that merge back

@christian-schilling
Copy link
Member

So you had pre-existing history in the Miri repo before you did the first pull via Josh 🤔
Or did Miri start outside of the main repo and "joined" in later?
In any case you have uncovered something here:
https://github.com/josh-project/josh/blob/master/src/history.rs#L466
This error comes from Josh, but from a line of code that was thought to unreachable (left there just in case)
So we'll need to reproduce this somehow in our tests and figure out how to make it work.

@oli-obk
Copy link
Author

oli-obk commented Sep 28, 2022

So you had pre-existing history in the Miri repo before you did the first pull via Josh 🤔

well, you can think about it the other way around. I did a clone with Josh and merged a random other history into that clone.

Or did Miri start outside of the main repo and "joined" in later?

effectively yes.

I'll see how your test work and try to produce a reproducer. There are like 5 other things that are very wrong with our history, but I'm mostly certain they are irrelevant.

@christian-schilling
Copy link
Member

Ok, for that use case the recommended way would have been the one described in the docs: You push your initial external history via Josh using the -o merge flag.
Or was there already some history in both places?

Running and writing tests for Josh is pretty easy (thanks docker) you can also ask on discord if you have questions.
I'm out for the day...

@RalfJung
Copy link
Contributor

RalfJung commented Oct 2, 2022

FWIW I also got that error in my experiments with pushing things from Miri to rust through josh

remote: josh-proxy
remote: response from upstream:
remote: rejecting merge with 2 parents:
remote: "Auto merge of #102328 - cuviper:ibm-stack-probes, r=nagisa"
remote: 
remote: 
remote: error: hook declined to update refs/heads/miri

In my case this had to do with this being a push for HEAD:miri, where the miri branch already exists -- despite me passing -o base=.... If I use a new branch instead that does not exist yet, it worked fine. Does -o base get ignored when the branch already exists?

@RalfJung
Copy link
Contributor

RalfJung commented Oct 2, 2022

What makes the 'bad push' different is that that history has two roots (commits without parent). So maybe that is what is causing the problem here.

@RalfJung
Copy link
Contributor

I think this can be closed in favor of #998. The issue here occurred with seriously strange histories, but now we are encountering similar errors with "normal" Rust/Miri history

@oli-obk oli-obk closed this as completed Oct 26, 2022
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

No branches or pull requests

4 participants