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

@asuffield asuffield commented Feb 18, 2021

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 (#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
7 of 9 checks passed
7 of 9 checks passed
@github-actions
version-matrix (1.13.x, ubuntu-latest) version-matrix (1.13.x, ubuntu-latest)
Details
@github-actions
test (master, ubuntu-latest)
Details
@github-actions
version-matrix (1.13.x, macos-latest) version-matrix (1.13.x, macos-latest)
Details
@github-actions
test (v2.11.0, ubuntu-latest) test (v2.11.0, ubuntu-latest)
Details
@github-actions
version-matrix (1.13.x, windows-latest)
Details
@github-actions
version-matrix (1.14.x, ubuntu-latest)
Details
@github-actions
version-matrix (1.14.x, macos-latest)
Details
@github-actions
version-matrix (1.14.x, windows-latest)
Details
coverage/coveralls First build on require-remote-ref at 83.722%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants