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

Remote: add RequireRemoteRefs to PushOptions #258

Merged
merged 1 commit into from Mar 25, 2021

Conversation

asuffield
Copy link
Contributor

The git protocol itself uses a compare-and-swap mechanism, where changes
send the old and new values and the change is only applied if the old
value matches. This is used to implement the --force-with-lease feature
in git push.

go-git populates the old field with the current value of the ref that
is read from the remote. We can implement a convenient (albeit more
limited) form of the --force-with-lease feature just by allowing the
caller to specify particular values for this ref.

Callers can then implement complex multi-step atomic operations by
reading the ref themselves at the start of the process, and passing to
in RequireRemoteRefs at the end. This is also a suitable building block
for implementing --force-with-lease (#101), which is mostly an exercise
in computing the correct hash to require. Hence, this appears to be the
most reasonable API to expose.

The git protocol itself uses a compare-and-swap mechanism, where changes
send the old and new values and the change is only applied if the old
value matches. This is used to implement the --force-with-lease feature
in git push.

go-git populates the `old` field with the current value of the ref that
is read from the remote. We can implement a convenient (albeit more
limited) form of the --force-with-lease feature just by allowing the
caller to specify particular values for this ref.

Callers can then implement complex multi-step atomic operations by
reading the ref themselves at the start of the process, and passing to
in RequireRemoteRefs at the end. This is also a suitable building block
for implementing --force-with-lease (go-git#101), which is mostly an exercise
in computing the correct hash to require. Hence, this appears to be the
most reasonable API to expose.
@mcuadros mcuadros changed the title add RequireRemoteRefs to PushOptions Remote: add RequireRemoteRefs to PushOptions Mar 25, 2021
@mcuadros mcuadros merged commit bf3471d into go-git:master Mar 25, 2021
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.

None yet

2 participants