-
Notifications
You must be signed in to change notification settings - Fork 61
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
Is it possible to avoid pushing new heads? #322
Comments
To some extent, it's a problem with git. But it's one we can do something about. We do detect this situation already, but only when the remote is fully up-to-date before pushing. So if you Here's a patch to the test to make the problem happen in the test suite.
I'm not sure when I'll get to actually fixing the issue. |
Thanks for having a look at this! The problem is compounded by the fact that our HG server rejects pushing new heads, and I'm not sure whether git-cinnabar handles rejected pushes correctly (whatever that would be…) However, I did look at the hg source, and I'm not sure anymore whether hg itself is actually able to detect the problem 100% of the time. It I read my notes correctly, they also only do that check on the client side (in |
Hi,
First: thanks for providing
git-cinnabar
! I now see a realistic chance to avoid working with Mercurial at my job, that would be great.The Problem
However, I have one problem that I cannot work around currently: Under certain (not so exotic, see below) circumstances,
git-cinnabar
does push new heads into the Mercurial repo without confirmation. Mercurial itself does not do this, ahg push
that would create a new head in the current branch fails with an error "abort: push creates new remote head …"With
git-cinnabar
, the behavior seems to depend on whethergit
already knows that it will push a new head at the time of push, i.e.:1.) Situation A Say you have a
git-cinnabar
repository, and you are currently on a remote-tracking branch. You dogit reset --hard 'HEAD^'
. Now, your next commit would be a new head in Mercurial terms (or a non-fast-forward in git terms…). If you now make a modification, commit and push, git rejects the push with the usual 'this is not a fast-forward' warning. This is exactly the behavior I want.2.) Situation B You have the same repository, but you do not do
git reset --hard 'HEAD^'
. So in your repository, it looks like your new commit neatly sits on top of the branch and should be a fast-forward. However, some other person has pushed to the branch since your lastgit pull
, and thus your new commit actually is not a fast-forward, but it would require a pull-and-rebase. If you now rungit push
,git-cinnabar
just seems to go ahead and push your commit as a new head without any confirmation or--force
. (See full reproduction below).Question
Is it possible to get
git-cinnabar
to also reject pushes in "Situation B" above, i.e., if the fact that a second head is being pushed is only discovered during push?Full Reproduction
This is a minimal example to reproduce the problem locally.
Step 1: Create new hg repo and a commit
Step 2: Clone a
git-cinnabar
repository from itStep 3: Add another commit to the hg repo
Step 4: Without pulling, create a commit in the git repo
Step 5: Push in the git repo
We're now in 'Situation B' from above. Let's push:
The
(+1 heads)
in the log above already gives away what has happened:git-cinnabar
has pushed a new head.Aftermath
This is how the repo looks like from git's perspective. Note that the second mercurial commit is still not visible in git:
And even after pulling, the new commit does not become visible (because from the
git-cinnabar
perspective, which tracks each Mercurial-head in a git-branch, it is part of a different branch):The hg repo now has a branch with two heads:
The text was updated successfully, but these errors were encountered: