OXYGENHUB
# 957fee30826e oxygen / docs / guide.md
17.1 KiB · Markdown · last changed Partial and interactive commits (commit PATH.., commit -i with hunk closure), oxy blame from atom keys, oxy bisect over dependency-closed prefixes with run and skip (spec 0.8 sections 12.3 and 27) 1 month ago renderedsource blame history raw
1
# Oxygen user guide
2
3
This guide is organised by task. It assumes the `oxy` binary is on your
4
path (`cargo build --release` puts it in `target/release/`). The design
5
behind every command is in [spec.md]spec.md; this guide only tells you
6
what to type and what to expect.
7
8
Oxygen tracks *changes* rather than snapshots: a change is the set of
9
edits you made, it commutes with unrelated changes, and conflicts are
10
recorded in history instead of blocking you. Two ideas recur below:
11
12
- A **bookmark** (default `main`) names a *state*: the set of changes it
13
  contains. A state can have several **heads** when independent changes
14
  have not been related to each other; that is normal, not a problem.
15
- The **working copy** is itself a change that Oxygen rewrites every time
16
  it looks at your files. `oxy commit` turns it into a real change.
17
18
Output uses colour and glyphs on a terminal; pipe it, pass `--plain`, or set
19
`NO_COLOR` for plain ASCII.
20
21
## 1. Set yourself up
22
23
```
24
oxy identity create --name "Ada Lovelace" --email [email protected]
25
oxy config --user core.sign change
26
```
27
28
`identity create` generates a composite Ed25519 + ML-DSA-65 key pair, keeps
29
the secret in `~/.config/oxy/keys/`, and records you as the default author
30
in `~/.config/oxy/config.toml`. With `core.sign = change` every commit is
31
signed; without it, changes are sealed in batches when you push (also
32
authenticated, just later). Use `--local` to record the identity in one
33
repository only.
34
35
`oxy identity show` prints the key, its expiry, delegates, and whether the
36
secret is available. `oxy identity export` writes the public identity to a
37
file to hand to whoever manages a trust policy (section 8).
38
39
## 2. Start a repository
40
41
```
42
mkdir project && cd project
43
oxy init
44
oxy status
45
```
46
47
`oxy init` creates `.oxy/`. Add `.oxyignore` (gitignore syntax, per
48
directory, negations with `!`) for files that should never be tracked;
49
`/target` and `*.tmp` are typical entries. As in Git, ignore rules only
50
affect untracked files: a file already in history stays tracked until you
51
delete it.
52
53
To take over an existing Git project, see section 12.
54
55
## 3. Everyday work
56
57
```
58
oxy status                 # what changed since the last commit
59
oxy diff                   # the edits, file by file
60
oxy commit -m "Add retry loop"
61
oxy log                    # newest first; -n 10, -v for full messages
62
oxy show 658990aa          # one change by ChangeId prefix, #hash prefix, or @
63
```
64
65
Commit part of what changed with `oxy commit PATH.. -m "..."` (only those
66
paths; the rest stays as uncommitted work) or `oxy commit -i -m "..."`, which
67
offers each hunk in turn like `git add -p`; a hunk that another chosen hunk
68
needs, such as the directory a new file lives in, comes along by itself.
69
70
`status --json` prints the same for tools, with every conflict's kind, path and
71
contributing ChangeIds. On a terminal, `status` lists each path with a mark: `✚ added`, `✎ modified`, `✖ removed`,
72
`➜ renamed`, `⚙ mode`. Renames are detected: a removed file and an added
73
file of the same kind whose contents are at least half alike are recorded
74
as a move of the same file, so identity survives a rename.
75
76
Files containing NUL bytes are stored whole ("opaque"); text files are
77
stored line by line and merge line by line. `.oxyattributes` overrides the
78
guess (section 14).
79
80
Every change has two names: a **ChangeId** (`658990aa…`) that survives
81
rewrites, and a content hash (`#7469d16c…`) that changes when the change is
82
edited. Use whichever you have; prefixes work.
83
84
## 3a. Bookmarks: branches without merges
85
86
A bookmark names a state; each workspace works on one (`main` to begin
87
with). Because changes commute, "merging" is the union of two bookmarks'
88
heads, with no merge change and any real conflict recorded as in section 6.
89
90
```
91
oxy bookmark create feature        # at the working copy's base
92
oxy bookmark switch feature        # check it out; commits now go here
93
oxy commit -m "Feature work"
94
oxy bookmark switch main
95
oxy merge feature                  # main now holds both; working copy follows if clean
96
oxy bookmark list                  # ● current, heads, ↑n/↓n against origin
97
oxy push -b feature                # publish a bookmark other than the current one
98
oxy bookmark set feature 658990aa  # move it; oxy bookmark delete feature to drop it
99
```
100
101
`oxy checkout feature` materialises a bookmark without switching to it, and
102
a bookmark name works wherever a change is expected when it has one head.
103
Each workspace remembers its own bookmark, so two directories can sit on
104
two bookmarks of one repository.
105
106
## 4. Fix up history
107
108
Oxygen keeps its own record of every operation, so all of these are safe to
109
try and to undo.
110
111
```
112
oxy describe -m "Better message"        # reword the head the working copy sits on
113
oxy describe 658990aa -m "..."          # reword any change; dependents are rewritten
114
oxy amend                               # fold the working copy into the head
115
oxy amend --into 658990aa               # fold it into an older change
116
oxy split 658990aa src/parser.rs        # split a head: those paths become a separate first change
117
oxy abandon 658990aa                    # drop a change; its content stays on disk
118
oxy undo                                # undo the last operation, whatever it was
119
oxy op log                              # the operation log
120
```
121
122
Rewriting a change that others depend on rewrites them too, keeping their
123
ChangeIds. Where a dependent referred to a line that no longer exists, the
124
reference is re-anchored to the nearest surviving line and `oxy abandon`
125
prints a note about it.
126
127
## 4a. Who wrote this, and what broke it
128
129
```
130
oxy blame src/parser.rs          # every line: the change that introduced it, author, age
131
oxy blame src/parser.rs --json
132
```
133
134
Blame is exact: each line is an atom that remembers the change that
135
introduced it, so renames cost nothing and there is no heuristic.
136
137
```
138
oxy bisect start
139
oxy bisect good v1.2             # a change, bookmark or tag known to be fine
140
oxy bisect bad main              # and one known to be broken
141
oxy bisect run make test         # exit 0 good, 125 skip, anything else bad
142
oxy bisect reset                 # back to where you were
143
```
144
145
Without `run`, each step checks out a state to test and you answer with
146
`oxy bisect good`, `bad`, or `skip`. The candidates are the changes the bad
147
state has that the good one lacks, ordered so every tested state is
148
well-formed; the answer is the first change whose inclusion breaks things.
149
150
## 5. Move around
151
152
```
153
oxy checkout                    # the bookmark's heads
154
oxy checkout 658990aa           # the state of one change and its dependencies
155
oxy checkout v1.2               # a tag
156
oxy checkout --discard ...      # throw away uncommitted work first
157
```
158
159
Checking out a single older change gives you the files that change and its
160
dependencies touch, not a full snapshot from that date: in Oxygen a change
161
depends only on what it actually builds on.
162
163
## 6. Conflicts
164
165
A conflict never stops a commit, fetch, or pull. It is recorded in the
166
state and shown by `oxy status`, which exits with status 2 while any
167
conflict remains. Conflicted text files are written with markers:
168
169
```
170
<<<<<<< oxy conflict 1 of 2, side 1: change k7m2p9 "Add retry loop"
171
... lines ...
172
======= oxy conflict 1 of 2, side 2: change q3x8w1 "Refactor client"
173
... lines ...
174
>>>>>>> oxy conflict 1 of 2 end
175
```
176
177
Edit the file to what it should be (keep one side, both, or neither) and
178
remove the markers. Tree conflicts, such as two files wanting the same
179
name, appear as `<name>.oxy-conflict-<n>` candidates: keep the one you
180
want under the right name and delete the rest.
181
182
```
183
oxy resolve      # which conflicts your edits resolve, which still have markers
184
oxy commit -m "Resolve retry vs refactor"
185
```
186
187
The commit is recorded as a *resolution*, a change that depends on every
188
side of the conflict; anyone who fetches it gets the conflict resolved.
189
190
## 7. Work with others
191
192
Run a server (any machine with the repositories under one directory):
193
194
```
195
oxy serve --root /srv/oxy --bind 0.0.0.0:8890 --token SECRET \
196
          --tls-cert cert.pem --tls-key key.pem
197
```
198
199
Without `--tls-*` the server speaks plain HTTP; keep that on a loopback
200
address or behind a TLS terminator. `--token` makes pushes require a bearer
201
token; reads stay open.
202
203
On your machine:
204
205
```
206
oxy clone https://host:8890/project
207
cd project
208
oxy config remote.origin.token SECRET   # or export OXY_TOKEN
209
oxy config remote.origin.ca my-ca.pem   # self-signed server: extra roots to trust (or OXY_CA)
210
oxy push
211
oxy pull
212
```
213
214
- `oxy fetch` updates `origin/main` without touching your bookmark.
215
- `oxy pull` fetches, then makes your bookmark the union of both sides.
216
  There is no merge commit; unrelated changes simply coexist, and a real
217
  conflict is recorded as in section 6. The working copy follows when it was
218
  clean.
219
- `oxy push` sends your changes and moves the remote bookmark. If the remote
220
  moved since you last fetched, the push is refused: pull and push again.
221
  `--force` overrides the compare-and-swap.
222
- `oxy remote add|remove|list` manages remotes; the clone source is `origin`.
223
224
A repository can also be cloned from a local path, which is handy for tests
225
and for a bare "hub" on a shared disk.
226
227
## 8. Decide who may publish: the trust policy
228
229
Without a policy a repository is *unverified*: everything is accepted and
230
every remote command says so. A policy names root keys and the keys allowed
231
to update each bookmark; servers and clients enforce it.
232
233
```
234
oxy policy init                    # your key becomes the only root; push publishes it
235
oxy policy show
236
oxy policy grant alice.identity    # alice.identity came from her `oxy identity export`
237
oxy policy grant ci.identity --pattern 'release/*'
238
oxy policy revoke 9458b656         # by KeyId prefix
239
oxy verify                         # signature status of every change in the log
240
```
241
242
Several people can hold root keys:
243
244
```
245
oxy policy root add bob.identity
246
oxy policy root threshold 2        # future updates need two root signatures
247
```
248
249
Once the threshold is above one, an update you make alone becomes a
250
*proposal file* (`policy-<serial>.proposal`, or `--out`). Send it to another
251
root holder, who runs `oxy policy sign policy-7.proposal`; whoever completes
252
the threshold applies it, and the next push publishes it. Everyone else
253
picks it up on fetch, verifying each step from the policy they already
254
trust.
255
256
## 9. Keys over time
257
258
```
259
oxy identity rotate                   # fresh key pair; old signatures stay valid
260
oxy identity renew --expires 365      # same keys, new expiry in days (0 = never)
261
oxy identity delegate add ci.identity # let another key sign on your behalf
262
oxy identity delegate remove 3f2a…
263
oxy identity revoke                   # retire your own key
264
oxy identity revoke 3f2a… --reason "laptop stolen"   # any key, if you hold a root
265
```
266
267
Rotation, renewal, and delegation all issue a successor identity that names
268
the previous one. If a policy names your key, it is updated to the successor
269
in the same step (as a proposal when more root signatures are needed).
270
Changes signed before the rotation remain authorised; a revoked key
271
authorises nothing. `oxy verify` shows signatures by revoked keys as valid
272
but revoked.
273
274
## 10. Tags and workspaces
275
276
```
277
oxy tag create v1.2 -m "First release"   # the current heads; or name changes
278
oxy tag list
279
oxy workspace add ../project-hotfix      # a second checkout sharing the repository
280
oxy workspace list
281
oxy workspace forget ../project-hotfix
282
```
283
284
A tag is an immutable state, signed when you have a key, and travels with
285
push and fetch. Workspaces have their own working copy and bookmark
286
(`workspace.bookmark`) but share objects and history.
287
288
## 11. Big repositories: partial, sparse, shallow
289
290
```
291
oxy clone URL --max-blob 1M          # files above 1 MiB are fetched on first read
292
oxy clone URL --sparse src --sparse docs   # materialise only these subtrees
293
oxy clone URL --depth 50             # only the last 50 levels of history
294
oxy sparse src docs tests            # change the filter later
295
oxy deepen 100                       # fetch more history below the boundary
296
```
297
298
Lazy blobs and sparse trees do not affect commits: what you do not have is
299
left exactly as it was. A shallow clone starts from a *checkpoint* of the
300
state, so status and commit work at full speed from the first minute.
301
302
## 11a. Nested repositories (submodules)
303
304
A subrepo is another repository checked out at a path and pinned to a state,
305
Oxygen or Git. The pin is versioned like a file, so two people pinning
306
different states get an ordinary conflict.
307
308
```
309
oxy submodule add https://host/lib.git libs/lib     # Git or Oxygen URL; records .oxymodules
310
oxy commit -m "Add lib"                              # the pin is committed with the parent
311
oxy submodule status                                 # pin vs what is on disk
312
oxy submodule update --init                          # after a clone: fetch nested repositories
313
oxy submodule remove libs/lib                        # drop the node; the directory stays
314
```
315
316
Committing the parent records whatever the nested repository is at, and
317
checking out an older parent state moves the nested repository back, unless
318
it has uncommitted changes, which are never overwritten. An absent nested
319
repository keeps its pin until you run `update --init`. Git submodules
320
survive `oxy git import` as Git pins and go back out as gitlinks on export.
321
322
## 12. Git interoperability
323
324
```
325
oxy git import ../project.git ./project-oxy --branch main   # convert a Git history
326
oxy git fetch https://github.com/you/project.git            # bring new Git commits in
327
oxy git push  https://github.com/you/project.git            # publish your changes to Git
328
oxy git export ../mirror.git                                # a plain Git mirror of the bookmark
329
```
330
331
Import turns each commit into one change (merge commits become
332
resolutions), keeps authors and hashes as `Git-Author`/`Git-Commit`
333
trailers, detects renames, and skips submodules. `git fetch`/`git push` keep
334
a bare mirror under `.oxy/git/`; a push is refused until the remote's tip
335
has been fetched, so it always fast-forwards. Exported commits carry
336
`Change-Id` and `Oxy-Hash` trailers.
337
338
## 13. Automate: hooks
339
340
Executables in `.oxy/hooks/<event>` (never cloned) receive one JSON object
341
on stdin. `pre-commit`, `pre-push` and other `pre-*` hooks veto by exiting
342
non-zero, and their stderr becomes the error message. Events:
343
`pre-commit`, `post-commit`, `pre-push`, `post-fetch`, `post-checkout`, and
344
`semantic-deps`, which runs at commit when `hooks.semantic-deps = true` and
345
answers `{"deps": ["<hash>", …]}` to make the change depend on more than it
346
textually references.
347
348
## 14. Per-path attributes, ignores, locks
349
350
`.oxyattributes` uses gitattributes syntax:
351
352
```
353
*.png     binary
354
*.txt     text eol=lf
355
*.psd     lockable nocompress
356
```
357
358
`binary`/`text` override content sniffing, `eol=lf|crlf` normalises line
359
endings in the store and on checkout, `nocompress` stores chunks raw, and
360
`lockable` files are checked out read-only until you take the local lock:
361
362
```
363
oxy lock assets/logo.psd
364
oxy unlock assets/logo.psd
365
```
366
367
Locks are advisory and local; server-side locks are planned.
368
369
## 15. Configuration
370
371
Two files, both `key = "value"` lines: `~/.config/oxy/config.toml`
372
(`oxy config --user KEY VALUE`) and `.oxy/config` (`oxy config KEY VALUE`).
373
The repository file wins. `OXY_HOME` relocates the user directory.
374
375
| Key | Meaning |
376
|---|---|
377
| `author.name`, `author.email`, `author.key` | who you are; `key` is set by `identity create` |
378
| `core.sign` | `change` to sign every commit; otherwise seals at push |
379
| `core.op-retention` | days for which old operations keep their states alive (90) |
380
| `core.gc-grace` | days an unreachable object survives (14) |
381
| `core.checkpoint-interval` | changes between automatic checkpoints (256) |
382
| `filter.max-blob`, `filter.paths` | lazy blobs and sparse subtrees (section 11) |
383
| `hooks.semantic-deps` | run the semantic-deps hook at commit |
384
| `workspace.bookmark` | this workspace's bookmark (`main`) |
385
| `remote.<name>.url`, `.token`, `.ca` | remotes; token and CA fall back to `OXY_TOKEN` and `OXY_CA` |
386
387
## 16. Shell prompt
388
389
`oxy prompt` prints `main 658990aa*+2` (bookmark, working copy, `*` dirty,
390
`!` conflicted, ahead/behind origin) in a few milliseconds and records
391
nothing. See [prompt.md]prompt.md for bash, oh-my-bash, zsh, and fish
392
snippets and the `--format` placeholders.
393
394
## 17. Housekeeping
395
396
```
397
oxy gc              # pack loose objects, prune unreachable ones past the grace period
398
oxy gc --now        # ignore the grace period (only when nothing else is writing)
399
oxy checkpoint      # serialise the bookmark's state so large histories load instantly
400
```
401
402
Both run automatically: packing when loose objects pile up, checkpoints
403
every `core.checkpoint-interval` changes.
404
405
## 18. If something looks wrong
406
407
- **"the remote has change … which you do not; pull first"**: someone
408
  pushed since your last fetch. `oxy pull`, then push.
409
- **"policy needs N root signature(s)"** on fetch: the server's policy was
410
  updated in a way your copy cannot verify. Ask a root holder whether the
411
  chain of updates was published; a fresh clone trusts the current policy.
412
- **`oxy status` exits 2**: conflicts remain; see section 6.
413
- **Many heads on `main`**: independent changes that do not reference one
414
  another. Nothing to fix; the state is their union.
415
- **Undo anything**: `oxy undo` reverts the last operation, including
416
  pulls, checkouts, and rewrites.