-
Notifications
You must be signed in to change notification settings - Fork 318
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
jj git push
: safety checks when pushing branch sideways, similar to git push --force-with-lease
#3522
Conversation
64c74f3
to
2d13e97
Compare
81b11aa
to
f7cec4f
Compare
8b7e930
to
bb9547c
Compare
e1511cf
to
f056679
Compare
This should be ready for review again. Apart from addressing the comments, I added a commit for adjusting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good to me, thanks!
c4d8ee4
to
eb6ba74
Compare
Adds two tests where pushing should fail, but currently succeeds.
This tests `git push` attempting to create a branch when the branch already unexpectedly exists on the remote. This should (and does) fail. Also changes another test to use `jj_cmd_failure`.
The new names are a bit clearer. Soem tests already use a `sideways_commit`, `parent_of_main_commit` will be needed in an upcoming test.
Hopefully, splitting the no-op portion will make the following commits easier to review.
As explained in the commit, our logic is a bit more complicated than that of `git push --force-with-lease`. This is to match the behavior of `jj git fetch` and branch conflict resolution rules.
This should be a no-op, though that is not necessarily obvious in corner cases. Note that libgit2 already performs the push negotiation even when pushing without force (without `+` in the refspec).
Now that we always force push, it should not occur in practice.
Thank you Yuya for the review! I plan to merge this tomorrow if I don't hear otherwise. If I hear from you earlier, I might merge it then. |
Previously,
jj git push
only made sure that the branch is in the expectedlocation on the remote server when pushing a branch forward (as opposed to
sideways or backwards). Now,
jj git push
makes a safety check in all casesand fails whenever
jj git fetch
would have introduced a conflict.In other words, previously branches that moved sideways or backward were
pushed similarly to Git's
git push --force
; now they have protectionssimilar to
git push --force-with-lease
(though not identical to it, to matchthe behavior of
jj git fetch
). Note also that because of the wayjj git fetch
works,jj
does not suffer from the same problems as Git'sgit push --force-with-lease
in situations whengit fetch
is run in the background.There are a few TODOs that may be added later (in this or separate PRs):
jj help git push
, possibly elsewhere.See TODOs in the code for more details. It's possible I forgot some, but it's probably time for others to look at the general form of this PR in any case.
Checklist
If applicable:
CHANGELOG.md