Fork
A fork is the user’s own note made from an upstream page. They edit it; upstream changes come through Compare (fork-update.md).
Provenance
Flat front matter keys, so Properties can show them. Upstream front matter is kept.
| Key | Value |
|---|---|
fork_remote | The source’s remote name |
fork_repo | Canonical repo URL; hosted sources only |
fork_path | Repo-relative path forked |
fork_branch | Branch forked from |
fork_commit | Head commit at fork time |
fork_blob | Blob at fork time: change marker and merge base |
fork_date | ISO datetime with offset |
fork_seen | Upstream blob dealt with without taking it, or gone. Absent until then |
fork_review | true: the text is wrapped for review (copy-safety.md). Not provenance |
A note is a fork when fork_path and fork_blob are valid and it has a valid fork_remote or
fork_repo. Writing a fork sets these and removes other fork_* and all mirror_* keys, so a
fork of a fork never keeps upstream’s provenance. A fork (or mirror) belongs to a source by
fork_remote (case-insensitive), else fork_repo (isFrom()).
Ways in
Fork on a file in What’s new, All files, or a mirror gone upstream (at the check’s head); Fork selected; Fork a file from a source; Fork this mirror (active note, no fetch). Markdown only; its attachments come with it (Attachments).
A mirrored file is moved, not fetched: renameFile (Obsidian updates links to it; mirrors and
the moved note get their text back, moveMirror()), keys mirror_* → fork_*, fork_date now,
text unchanged but for its links. Never copied: two notes of one name would split every link by
name. Its own path doesn’t count as taken. Of a file mirrored twice (copied by hand), Fork this
mirror moves the active note, anything else the first by path. If upstream has moved on, the
next check lists it under Forks.
The modal
One modal for one file or several.
Folders:
- Into the folder: each file into Folder under its own name.
- Into the folder, keeping source folders:
wiki/cs/git.md+notes/research→notes/research/wiki/cs/git.md. - Same folder as in the source: the same path in the vault.
Missing folders are created. Fixed at Into the folder when no file has a folder.
Folder: empty is the vault root. Suggests up to 50 vault folders; free text. End slashes dropped;
./..parts or a file path are errors.
Opens on Same folder as in the source when matchFolders is on and any file has a folder;
else Into the folder. Folder starts as forkFolder. The modal says so until edited. The
typed folder survives switching choices. A fork can’t go in follows/, the clones folder, or a
source’s mirror folder (copy-safety.md): the modal says so.
The community folder around the mirror folders is fine.
One file also has Name (no .md): the source name, or the first free <name> 1, 2, …
with a note saying so. It follows the destination until typed in; then it must be free. Empty,
/ or \ is an error. Earlier forks of the file are named.
Convert links and Match links to existing pages, applied once the forks are written: links.md.
Preview, redrawn on change: “Goes to <path>”, or a row per file (source → vault, “Name
taken.” when numbered (case-insensitive), “Forked before.”, “Its mirror moves.”), plus folders
to be made. An error replaces it and disables Fork / Fork all. Enter forks. Nothing is
overwritten.
Writing
Per unmirrored file: fetch blob, create note, add keys (processFrontMatter). The blobs are all
read once the modal is answered, and checked before any is written (copy-safety.md).
Invalid upstream YAML is refused before writing.
- One file: notice, the note opens. Failure shows in the modal, which stays open.
- Several: each in turn, continuing past failures; one notice (sticky if any failed); nothing opened. Ticks are cleared.
Attachments
The files that aren’t Markdown a fork links or embeds, found as a mirror’s are
(mirror.md), when they are beside the note upstream: in its folder or
below (isBeside()). They go as far from the fork (besidePath()): wiki/cs/git.md with
wiki/cs/img/a.png, forked to notes/git.md → notes/img/a.png. So the fork’s links find them
unchanged, and nothing is written outside the fork’s folder.
- Not beside (
../assets/a.png, a shared folder, a name found elsewhere): not copied; the notice names them, and their links stay broken. - A file already there: left. The same bytes need nothing (two forks in one folder share an image); different ones are the user’s, and the notice names them.
- A forked mirror: its attachments are copied from the mirror folder, not moved: other mirrors may use them. Not fetched.
Copied after the notes are written, before one is opened, so its images show. Then they are the user’s: Compare, overwrite and write alongside don’t touch them, and nothing tracks them.
Code
Pure: src/fork/destination.ts, fork.ts, src/copy/copy.ts, attachments.ts, src/sources/fork-meta.ts,
src/check/selection.ts. Vault: src/fork/run.ts, attachments-run.ts, command.ts, src/copy/run.ts,
src/sources/forks.ts. UI: src/ui/fork-modal.ts, fork-preview.ts, folder-suggest.ts.