mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-10-30 08:20:47 +08:00
The rules for checking the quorum of the remote helper, when pushing to the canonical branch, can prevent the operator from even attempting to try converge to a state of agreeance. Instead, the checking of the quorum rules are relaxed. It is still the case that if the peer is pushing a diverging commit while in a working state they are warned and the push does not go through. However, there are two cases where it is fine to force push a change: 1. When pushing a new tip, as a delegate, there is still a canonical tip and the new tip still converges with the history, i.e. it is equal to, behind, or ahead of another delegate tip. 2. If there is no quorum in the current state, for example there were multiple concurrent pushes, then the peer is free to continue to push to their default branch in attempt to converge with the other peers. The example tests ensure that these cases are covered, while also preserving the old behaviour. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
81 lines
3.1 KiB
Markdown
81 lines
3.1 KiB
Markdown
|
|
Let's see what happens if we try to push a head which diverges from the
|
|
canonical head.
|
|
|
|
First we add a second delegate, Bob, to our repo:
|
|
|
|
``` ~alice
|
|
$ rad id update --title "Add Bob" --description "" --delegate did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --repo rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji -q
|
|
c036c0d89ce26aef3ad7da402157dba16b5163b4
|
|
```
|
|
|
|
Then, as Bob, we commit some code on top of the canonical head:
|
|
|
|
``` ~bob
|
|
$ rad sync --fetch
|
|
✓ Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from z6MknSL…StBU8Vi..
|
|
✓ Fetched repository from 1 seed(s)
|
|
$ rad inspect --delegates
|
|
did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (alice)
|
|
did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (bob)
|
|
$ git commit -m "Third commit" --allow-empty -q
|
|
$ git push rad
|
|
$ git branch -arv
|
|
alice@z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi/master f2de534 Second commit
|
|
rad/master 319a7dc Third commit
|
|
```
|
|
|
|
As Alice, we fetch that code, but commit on top of our own master, which is no
|
|
longer canonical, since Bob pushed a more recent commit, and the threshold is 1:
|
|
|
|
``` ~alice
|
|
$ rad remote add did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --fetch --no-sync
|
|
✓ Remote bob@z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk added
|
|
✓ Remote-tracking branch bob@z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk/master created for z6Mkt67…v4N1tRk
|
|
$ git branch -arv
|
|
bob@z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk/master 319a7dc Third commit
|
|
rad/master f2de534 Second commit
|
|
$ git commit -m "Third commit by Alice" --allow-empty -q
|
|
```
|
|
|
|
If we try to push now, we get an error with a hint, telling us that we need to
|
|
integrate Bob's changes before pushing ours:
|
|
|
|
``` ~alice (stderr) (fail) RAD_HINT=1
|
|
$ git push rad
|
|
hint: you are attempting to push a commit that would cause your upstream to diverge from the canonical head
|
|
hint: to integrate the remote changes, run `git pull --rebase` and try again
|
|
error: refusing to update branch to commit that is not a descendant of canonical head
|
|
error: failed to push some refs to 'rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi'
|
|
```
|
|
|
|
We do that, and notice that we're now able to push our code:
|
|
|
|
``` ~alice
|
|
$ git pull --rebase
|
|
$ git log --oneline
|
|
f6cff86 Third commit by Alice
|
|
319a7dc Third commit
|
|
f2de534 Second commit
|
|
08c788d Initial commit
|
|
```
|
|
``` ~alice RAD_SOCKET=/dev/null (stderr)
|
|
$ git push rad
|
|
✓ Canonical head updated to f6cff86594495e9beccfeda7c20173e55c1dd9fc
|
|
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
|
f2de534..f6cff86 master -> master
|
|
```
|
|
|
|
One thing of note is that we can revert to an older commit as long as we are
|
|
still ahead of the other delegates.
|
|
|
|
``` ~alice
|
|
$ git reset --hard HEAD^ -q
|
|
```
|
|
``` ~alice RAD_SOCKET=/dev/null (stderr)
|
|
$ git push -f
|
|
✓ Canonical head updated to 319a7dc3b195368ded4b099f8c90bbb80addccd3
|
|
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
|
+ f6cff86...319a7dc master -> master (forced update)
|
|
```
|