Blame


1 cb49e6af 2019-08-14 stsp All this is assuming operation against a custom gotd(8) server which
2 2bcee280 2019-08-14 stsp would queue up incoming commits and attempt a 'trivial-rebase' operation
3 2bcee280 2019-08-14 stsp for each commit in sequence. Commits which fail 'trivial-rebase' are
4 2bcee280 2019-08-14 stsp rejected and reported as 'out-of-date' to the client.
5 cb49e6af 2019-08-14 stsp
6 cb49e6af 2019-08-14 stsp 'trivial-rebase' merges trees successfully as long as all file content
7 cb49e6af 2019-08-14 stsp changes apply to the expected 'base blob' content (which implies a
8 cb49e6af 2019-08-14 stsp conflict-free file merge according to diff3), all added blobs get
9 cb49e6af 2019-08-14 stsp added where no blob exists yet, and only existing blobs get deleted.
10 cb49e6af 2019-08-14 stsp
11 8913f071 2019-08-14 stsp (As an analogy, this part of gotd(8) would operate roughly like some
12 8913f071 2019-08-14 stsp sort of Gerrit server with merge strategy set to 'rebase-if-necessary',
13 671dfedb 2019-08-14 stsp but without a code review UI and without Java.)
14 1aeed1b9 2019-08-14 stsp
15 81889954 2019-08-14 stsp gotd(8) would also regulate read/write access to branches and perform
16 6ef7de4c 2019-08-14 stsp various sanity checks on commits: require a log message, reject merge
17 6ef7de4c 2019-08-14 stsp commits except where necessary (e.g. merges of vendor branches), ...
18 6ef7de4c 2019-08-14 stsp
19 1aeed1b9 2019-08-14 stsp Another responsibility of gotd(8) would be to keep repo mirrors in sync.
20 1aeed1b9 2019-08-14 stsp
21 cb49e6af 2019-08-14 stsp ---
22 cb49e6af 2019-08-14 stsp
23 cb49e6af 2019-08-14 stsp got pull:
24 cb49e6af 2019-08-14 stsp
25 cb49e6af 2019-08-14 stsp fetch latest master branch from server to local origin/master
26 cb49e6af 2019-08-14 stsp origin/master has new commits
27 cb49e6af 2019-08-14 stsp if fast-forward possible:
28 cb49e6af 2019-08-14 stsp set master -> origin/master
29 cb49e6af 2019-08-14 stsp if running in a worktree: {
30 cb49e6af 2019-08-14 stsp if fast-forward was possible:
31 710504c4 2019-08-14 stsp automatically run 'got update' ('got pull' implies 'got up')
32 cb49e6af 2019-08-14 stsp else:
33 cb49e6af 2019-08-14 stsp attempt server-style trivial-rebase of master onto origin/master
34 cb49e6af 2019-08-14 stsp if success:
35 cb49e6af 2019-08-14 stsp set work tree's branch to rebased master branch (implied got up -b)
36 cb49e6af 2019-08-14 stsp else:
37 cb49e6af 2019-08-14 stsp require manual rebase + resolve conflicts
38 cb49e6af 2019-08-14 stsp } else:
39 cb49e6af 2019-08-14 stsp existing worktrees will have to be updated/rebased manually
40 cb49e6af 2019-08-14 stsp
41 cb49e6af 2019-08-14 stsp ---
42 cb49e6af 2019-08-14 stsp
43 cb49e6af 2019-08-14 stsp got push:
44 cb49e6af 2019-08-14 stsp
45 cb49e6af 2019-08-14 stsp attempt push + trivial-rebase on server
46 cb49e6af 2019-08-14 stsp out-of-date ? -> require 'got pull'
47 cb49e6af 2019-08-14 stsp
48 cb49e6af 2019-08-14 stsp ---
49 cb49e6af 2019-08-14 stsp
50 ab7a017f 2019-08-14 stsp "push by default" commits allow for "branchless" development (committing
51 ab7a017f 2019-08-14 stsp local changes against a central server and local repo at the same time)
52 cb49e6af 2019-08-14 stsp
53 cb49e6af 2019-08-14 stsp got checkout
54 cb49e6af 2019-08-14 stsp
55 cb49e6af 2019-08-14 stsp work work work
56 cb49e6af 2019-08-14 stsp
57 30823816 2019-08-14 stsp get OKs for your local changes!
58 ab7a017f 2019-08-14 stsp
59 ab7a017f 2019-08-14 stsp got OKs?
60 ab7a017f 2019-08-14 stsp (optionally: stage OK'd changes with 'got stage')
61 cb49e6af 2019-08-14 stsp got commit
62 cb49e6af 2019-08-14 stsp create temp commit object; attempt push + trivial-rebase on server
63 cb49e6af 2019-08-14 stsp if success:
64 cb49e6af 2019-08-14 stsp temp commit becomes new head of local master
65 cb49e6af 2019-08-14 stsp optionally, user may run 'got pull' to rebase local version of master
66 8913f071 2019-08-14 stsp else:
67 ab7a017f 2019-08-14 stsp (require unstage if changes were staged)
68 cb49e6af 2019-08-14 stsp require got pull
69 cb49e6af 2019-08-14 stsp try to commit again
70 cb49e6af 2019-08-14 stsp
71 671dfedb 2019-08-14 stsp (The fossil SCM has already implemented an implied-push-on-commit design.)
72 671dfedb 2019-08-14 stsp
73 cb49e6af 2019-08-14 stsp ---
74 cb49e6af 2019-08-14 stsp
75 cb49e6af 2019-08-14 stsp repo/gotconfig syntax ideas:
76 cb49e6af 2019-08-14 stsp
77 e0d5257d 2019-08-14 stsp [[[
78 071f7ad8 2019-08-14 stsp # remote private mirrors
79 e0d5257d 2019-08-14 stsp remote "openbsd_src" {
80 e0d5257d 2019-08-14 stsp repository "src"
81 e0d5257d 2019-08-14 stsp server got.openbsd.org
82 e0d5257d 2019-08-14 stsp protocol ssh
83 e0d5257d 2019-08-14 stsp user stsp
84 e0d5257d 2019-08-14 stsp }
85 e0d5257d 2019-08-14 stsp remote "my_src_mirror" {
86 e0d5257d 2019-08-14 stsp repository "src"
87 e0d5257d 2019-08-14 stsp server got.stsp.name
88 e0d5257d 2019-08-14 stsp protocol ssh
89 e0d5257d 2019-08-14 stsp user stsp
90 e0d5257d 2019-08-14 stsp }
91 cb49e6af 2019-08-14 stsp
92 071f7ad8 2019-08-14 stsp # remote public mirrors
93 e0d5257d 2019-08-14 stsp remote "public_src_mirror_anonssh" {
94 e0d5257d 2019-08-14 stsp repository "src"
95 e0d5257d 2019-08-14 stsp server got.stsp.name
96 e0d5257d 2019-08-14 stsp protocol ssh
97 e0d5257d 2019-08-14 stsp user anonymous
98 e0d5257d 2019-08-14 stsp }
99 e0d5257d 2019-08-14 stsp remote "public_src_mirror" {
100 e0d5257d 2019-08-14 stsp repository "src"
101 e0d5257d 2019-08-14 stsp server got.stsp.name
102 e0d5257d 2019-08-14 stsp protocol https
103 5185bb1d 2019-08-14 stsp # no authentication credentials for this remote since https is read-only
104 e0d5257d 2019-08-14 stsp }
105 071f7ad8 2019-08-14 stsp
106 071f7ad8 2019-08-14 stsp # read from local mirror and push to main server
107 40100c4d 2019-08-14 stsp # "sync-to" enables push by default with 'got commit'
108 071f7ad8 2019-08-14 stsp # implied mapping: refs/heads/master <-> refs/remotes/openbsd_src/master
109 071f7ad8 2019-08-14 stsp branch master pull-from my_src_mirror sync-to openbsd_src
110 cb49e6af 2019-08-14 stsp
111 071f7ad8 2019-08-14 stsp # read from local mirror and push to local mirror
112 40100c4d 2019-08-14 stsp # "push-to" means commit locally, push manually
113 071f7ad8 2019-08-14 stsp # implied mapping: refs/heads/my_branch <-> refs/remotes/my_src_mirror/my_branch
114 071f7ad8 2019-08-14 stsp branch my_branch pull-from my_src_mirror push-to my_src_mirror
115 b3a62bf5 2019-08-14 stsp
116 bf62ff8d 2019-08-14 stsp # same as above, pull from and push to local mirror:
117 bf62ff8d 2019-08-14 stsp branch my_branch remote my_src_mirror
118 071f7ad8 2019-08-14 stsp
119 bf62ff8d 2019-08-14 stsp # pull from and push to local mirror, use push by default with 'got commit'
120 bf62ff8d 2019-08-14 stsp branch synced_branch sync-with my_src_mirror
121 bf62ff8d 2019-08-14 stsp
122 071f7ad8 2019-08-14 stsp # read-only access, anoncvs-style
123 071f7ad8 2019-08-14 stsp branch master pull-from public_src_mirror_anonssh
124 071f7ad8 2019-08-14 stsp
125 071f7ad8 2019-08-14 stsp # read-only access over https
126 071f7ad8 2019-08-14 stsp branch master pull-from public_src_mirror
127 e0d5257d 2019-08-14 stsp ]]]
128 071f7ad8 2019-08-14 stsp
129 e0d5257d 2019-08-14 stsp read-only config for just keeping /usr/src up-to-date with 'got update':
130 e0d5257d 2019-08-14 stsp
131 e0d5257d 2019-08-14 stsp [[[
132 e0d5257d 2019-08-14 stsp remote "origin" {
133 e0d5257d 2019-08-14 stsp repository "src"
134 e0d5257d 2019-08-14 stsp server got.openbsd.mirror.example.com
135 e0d5257d 2019-08-14 stsp protocol https
136 61fa5be1 2019-08-14 stsp mirror-references # map refs/* <-> refs/*
137 e0d5257d 2019-08-14 stsp }
138 e0d5257d 2019-08-14 stsp # mapping: refs/heads/master <-> refs/heads/master
139 61fa5be1 2019-08-14 stsp branch "master" pull-from "origin"
140 e0d5257d 2019-08-14 stsp ]]]
141 0e11765d 2019-08-14 stsp
142 0e11765d 2019-08-14 stsp ---
143 0e11765d 2019-08-14 stsp
144 0e11765d 2019-08-14 stsp Known implications of the above design for the implementation:
145 0e11765d 2019-08-14 stsp
146 0e11765d 2019-08-14 stsp For each changed file, the 'trivial-rebase' operation needs to know the
147 0e11765d 2019-08-14 stsp ID of the blob which the new file content is based on ("base-blob ID").
148 0e11765d 2019-08-14 stsp Otherwise the out-of-dateness check in 'trivial-rebase' cannot work.
149 0e11765d 2019-08-14 stsp To satisfy this requirement, the client<->server protocol could require file
150 0e11765d 2019-08-14 stsp content modifications in a chain of commits being pushed to be expressed
151 0e11765d 2019-08-14 stsp in terms of GOT_OBJ_TYPE_REF_DELTA objects against known base blob IDs.
152 0e11765d 2019-08-14 stsp The client can read such base blob IDs from the latest commit in its copy
153 0e11765d 2019-08-14 stsp of the branch (e.g. refs/remotes/origin/master).
154 0e11765d 2019-08-14 stsp
155 0e11765d 2019-08-14 stsp For simplicity, it might make sense to require the protocol to express
156 0e11765d 2019-08-14 stsp all file modifications in this way (GOT_OBJ_TYPE_REF_DELTA).
157 0e11765d 2019-08-14 stsp File additions could be expressed as a delta against the empty blob's hash
158 0e11765d 2019-08-14 stsp as a base. File deletions could send a delta which simply deletes all content
159 0e11765d 2019-08-14 stsp from the specified base blob in addition to an explicit 'delete' command to
160 0e11765d 2019-08-14 stsp allow the server to distinguish this case from an empty file on disk.
161 0e11765d 2019-08-14 stsp
162 e0077a0d 2021-09-22 stsp The above functionality could be implemented via a Git protocol extension.