clonetree_linux-amd64 0.1.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,46 +1,162 @@
1
- # Clonetree
1
+ <div align="center">
2
+ <img src="docs/assets/clonetree.svg" alt="Clonetree: geometric canopies with fine tree branches and a new side branch" width="128" height="128">
3
+ <h1>clonetree</h1>
4
+ <p><strong>Clone your checkout. Share its storage.</strong></p>
5
+ <p>Keep local edits, installed dependencies, and build output.</p>
6
+ <p>
7
+ <a href="#quick-start"><strong>Quick start</strong></a> ·
8
+ <a href="#coming-from-git-worktrees"><strong>Git worktrees</strong></a> ·
9
+ <a href="#everyday-usage"><strong>Usage</strong></a> ·
10
+ <a href="#how-it-works"><strong>How it works</strong></a>
11
+ </p>
12
+ <p>
13
+ <a href="https://github.com/sprisa/clonetree/actions/workflows/test.yml"><img src="https://github.com/sprisa/clonetree/actions/workflows/test.yml/badge.svg" alt="Tests"></a>
14
+ <a href="https://www.npmjs.com/package/clonetree"><img src="https://img.shields.io/npm/v/clonetree?color=A7B7A0" alt="npm version"></a>
15
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MPL%202.0-blue" alt="License: MPL 2.0"></a>
16
+ </p>
17
+ </div>
2
18
 
3
- Snapshot any directory using copy-on-write filesystem clones.
19
+ **clonetree** creates a working copy of the current directory using filesystem
20
+ clones. It provides a create/list/delete workflow similar to Git worktrees,
21
+ starting from the files on disk rather than a commit.
22
+
23
+ - **Clone local edits.** Uncommitted changes, untracked files, and ignored files
24
+ are included.
25
+ - **Keep dependencies installed.** Existing dependency directories and build
26
+ output are included alongside source files.
27
+ - **Share file storage.** Files are separate, but their existing data is not
28
+ copied again. More space is used as either copy changes.
29
+
30
+ In our [APFS benchmark](#benchmark), a **39.2 GiB checkout** cloned in **55 seconds**
31
+ on average, with **~88–93 MiB** of estimated additional disk usage.
32
+
33
+ **Requires macOS with APFS, or Linux with reflink-enabled XFS/Btrfs.** Source and
34
+ destination must be on the same filesystem. No Git repository is required.
35
+
36
+ ## Install
4
37
 
5
38
  ```sh
6
- # with brew (auto-updates)
39
+ # Homebrew
7
40
  brew install sprisa/tap/clonetree
8
- # with npm (auto-updates)
41
+
42
+ # npm
9
43
  npx clonetree
10
- # with go (no auto-updates)
11
- go install github.com/sprisa/clonetree@latest
12
44
 
13
- # From the directory you want to snapshot:
14
- clonetree init
15
- clonetree new my-feature # creates ./clonetree/my-feature.clonetree/
45
+ # Go 1.24+
46
+ go run github.com/sprisa/clonetree@latest
47
+ ```
48
+
49
+ Or run without a global installation: `npx clonetree --help`.
50
+
51
+ ## Quick start
52
+
53
+ From the directory you want to clone:
54
+
55
+ ```sh
56
+ clonetree init # Add *.clonetree/ to this directory's .gitignore
57
+ clonetree new my-feature # Clone into ./clonetree/my-feature.clonetree/
58
+ cd clonetree/my-feature.clonetree
59
+
60
+ # Files, local edits, and installed dependencies are included.
61
+ ```
62
+
63
+ `init` is a one-time convenience for ignoring snapshots. It doesn't create a
64
+ repository or a snapshot; `new` does the cloning. Directories ending in
65
+ `.clonetree` are skipped, so new snapshots don't contain your older ones.
66
+
67
+ Back in the original directory, inspect or remove your workspace:
68
+
69
+ ```sh
16
70
  clonetree info
17
- clonetree delete my-feature
71
+ clonetree delete my-feature # Removes the workspace, including its local changes
18
72
  ```
19
73
 
20
- - The source is always the current directory; no repository is required.
21
- - `init` creates or updates `.gitignore` here with `*.clonetree/`.
22
- - `new <id>` creates `clonetree/<id>.clonetree/`, including hidden files, ignored files, dependencies, and any `.git` or `.sl` metadata.
23
- - `--dir` / `-d` changes the snapshot parent for `new`, `info`, and `delete`; relative paths are resolved from the current directory. Use `--dir .` to put snapshots here directly.
24
- - Directories ending in `.clonetree` are skipped at every depth, including the destination itself.
25
- - Reports clone time and estimated additional disk usage.
26
- - Live progress is enabled by default when stderr is a TTY; `--no-progress` explicitly disables it.
27
- - Interactive cloning counts entries first, then shows a percentage bar, entries/second, and estimated time remaining. Non-TTY and disabled runs skip that counting pass and keep output plain.
28
- - Added disk usage is a filesystem free-space estimate; other activity and delayed accounting can affect it.
29
- - `info` lists snapshots in the selected directory with live logical sizes and private storage where available (APFS); `n/a` means unavailable.
30
- - Private storage excludes shared blocks and filesystem-wide metadata overhead.
31
- - Files share storage until either checkout changes. Old data stays allocated while any clone needs it; a clone's private usage can grow when the original changes or is deleted.
32
- - Uses native APFS clones on macOS and XFS/Btrfs reflinks on Linux; no full-copy fallback. Ext4 is unsupported.
33
- - macOS reads metadata in native batches with reusable buffers; standard metadata reads handle unsupported filesystems and exceptional entries.
34
- - Requires Go 1.24+ to install.
35
- - Preserves permissions, modification times, and symlink targets. Stop writers while cloning; snapshots are not atomic.
36
- - VCS metadata is copied as-is, including lock files. External stores and absolute paths retain their references.
37
- - A cloned subdirectory is not automatically a new checkout; Git/Sapling can still discover the original parent repository.
38
- - Run `clonetree --help` or `clonetree <command> --help` for details.
39
- - Licensed under [MPL-2.0](LICENSE).
74
+ ## Coming from Git worktrees
75
+
76
+ The equivalent commands:
77
+
78
+ | What you want to do | Git worktree | clonetree |
79
+ | --- | --- | --- |
80
+ | Create a workspace | `git worktree add ../my-feature -b my-feature` | `clonetree new my-feature` |
81
+ | List workspaces | `git worktree list` | `clonetree info` |
82
+ | Remove a workspace | `git worktree remove ../my-feature` | `clonetree delete my-feature` |
83
+
84
+ The important difference is **what you start with**:
85
+
86
+ | | Git worktree | clonetree |
87
+ | --- | --- | --- |
88
+ | Starting point | A checked-out commit or branch | Your current directory, including local edits |
89
+ | Dependencies and ignored files | Not populated from the original workspace | Included if present in the source |
90
+ | Working-file storage | A separate working tree | Shared data blocks until files change |
91
+ | Git relationship | Linked to the same repository | Repository metadata is cloned as-is |
92
+
93
+ **Git worktrees already share Git objects.** Clonetree also shares the storage
94
+ behind working files, so a large `node_modules/` or build directory can come along
95
+ without another full copy of its contents.
96
+
97
+ A clonetree ID names a directory, not a branch. In a regular Git checkout with its
98
+ own `.git` directory, the clone gets its own Git metadata too: you can use the same
99
+ branch independently, or create a new one after entering the clone:
100
+
101
+ ```sh
102
+ git switch -c my-feature
103
+ ```
104
+
105
+ Commits and refs in that clone aren't automatically synchronized with the source;
106
+ share them through your usual Git remote. Clonetrees aren't registered in
107
+ `git worktree list`. If your source is a linked worktree or uses external metadata,
108
+ read the [repository metadata details](#repository-metadata) below.
109
+
110
+ ## Everyday usage
111
+
112
+ ### Choose a snapshot directory
113
+
114
+ The source is always your current directory. `--dir` (or `-d`) changes the parent
115
+ directory used by `new`, `info`, and `delete`:
116
+
117
+ ```sh
118
+ clonetree --dir ../workspaces new experiment
119
+ clonetree --dir ../workspaces info
120
+ clonetree --dir ../workspaces delete experiment
121
+ ```
122
+
123
+ This creates `../workspaces/experiment.clonetree/`. Relative paths are resolved
124
+ from the current directory; use the same parent when listing or deleting. Use
125
+ `--dir .` to create snapshots directly here instead of inside `./clonetree/`.
126
+
127
+ ### Inspect disk usage
128
+
129
+ `new` reports clone time and estimated additional disk usage. `info` scans your
130
+ snapshots and shows their logical size and private storage where available:
131
+
132
+ | Column | Meaning |
133
+ | --- | --- |
134
+ | `SIZE` | Logical file content, including data shared with other clones |
135
+ | `PRIVATE` | Storage not shared with another clone or filesystem snapshot (APFS); `n/a` when unavailable |
136
+
137
+ ### Control progress output
138
+
139
+ Interactive runs show a progress bar, entries per second, and estimated time
140
+ remaining. For plain output:
141
+
142
+ ```sh
143
+ clonetree --no-progress new experiment
144
+ ```
145
+
146
+ Non-interactive runs disable progress automatically. Both non-interactive and
147
+ `--no-progress` runs skip the initial entry-counting pass.
40
148
 
41
149
  ## Benchmark
42
150
 
43
- Two non-interactive full-checkout runs on an Apple M4 Max with 128 GiB RAM, macOS 27.0.1, and APFS.
151
+ **A 39.2 GiB checkout, cloned in 55 seconds on average, using about 88–93 MiB of
152
+ additional disk space.** That includes dependencies, Git metadata, and ignored files.
153
+
154
+ Two non-interactive full-checkout runs on an Apple M4 Max with 128 GiB RAM,
155
+ macOS 27.0.1, and APFS. Additional disk usage is a filesystem free-space estimate;
156
+ timings and space usage vary with filesystem state and other disk activity.
157
+
158
+ <details>
159
+ <summary><strong>Full benchmark results</strong></summary>
44
160
 
45
161
  | Metric | Result |
46
162
  | --- | ---: |
@@ -55,11 +171,69 @@ Two non-interactive full-checkout runs on an Apple M4 Max with 128 GiB RAM, macO
55
171
  | Total source lines, including comments and blanks | 627,040 |
56
172
  | Lines of code | 518,265 |
57
173
 
58
- Copy-on-write shares existing data blocks; additional space grows as files change.
59
- Timings and space estimates vary with filesystem state and other disk activity.
60
-
61
174
  See [performance notes](PERFORMANCE.md) for allocation benchmarks, escape-analysis
62
175
  findings, and collection-disabled memory measurements.
63
176
 
64
- See [testing](TESTING.md) for native XFS/Btrfs e2e tests in Ubuntu Docker or a VM,
65
- and APFS tests on a macOS host.
177
+ </details>
178
+
179
+ ## How it works
180
+
181
+ ### Native copy-on-write
182
+
183
+ Clonetree walks the current directory and asks the filesystem to clone each file.
184
+ The new files initially share data blocks with the originals. Editing either file
185
+ allocates storage for its changes without changing the other file's contents.
186
+
187
+ | Platform | Native cloning |
188
+ | --- | --- |
189
+ | macOS | APFS clones |
190
+ | Linux | XFS/Btrfs reflinks; reflink support must be enabled |
191
+
192
+ Clonetree uses native cloning only, with no full-copy fallback. Ext4, Windows, and
193
+ cross-filesystem clones are unsupported. On macOS, metadata is read in native
194
+ batches with reusable buffers; standard metadata reads handle unsupported
195
+ filesystems and exceptional entries.
196
+
197
+ ### Included files
198
+
199
+ - Hidden files, ignored files, installed dependencies, and any `.git` or `.sl`
200
+ metadata are included. Git's ignore rules don't filter the clone.
201
+ - Directories ending in `.clonetree` are excluded at every depth, including the
202
+ destination itself.
203
+ - Permissions, modification times, and symlink targets are preserved. Absolute
204
+ symlinks still point to their original targets.
205
+ - Existing IDs are never overwritten. Failed or cancelled clones are removed.
206
+
207
+ ### Repository metadata
208
+
209
+ Clonetree copies VCS metadata as-is, including lock files. It doesn't rewrite
210
+ linked/shared stores or absolute metadata paths. For a self-contained Git
211
+ workspace, start at a repository root with its own `.git` directory.
212
+
213
+ A linked Git worktree's `.git` file still points to its original metadata after
214
+ cloning. Submodules and external stores retain their references too. Cloning a
215
+ subdirectory doesn't automatically create a new checkout: Git or Sapling may still
216
+ discover the original parent repository.
217
+
218
+ ### Storage and consistency
219
+
220
+ - Files share storage until either workspace changes. Old data stays allocated
221
+ while any clone needs it; a clone's private usage can grow when the original
222
+ changes or is deleted.
223
+ - Added disk usage is estimated from filesystem free space. Other disk activity
224
+ and delayed accounting can affect it.
225
+ - Private storage excludes shared blocks and filesystem-wide metadata overhead.
226
+ Measurements are scanned live, and unavailable values appear as `n/a`.
227
+ - Cloning is not an atomic directory-wide snapshot. Stop writers and let VCS
228
+ operations finish before cloning if you need a consistent starting point.
229
+
230
+ ## Learn more
231
+
232
+ | Looking for… | Start here |
233
+ | --- | --- |
234
+ | Commands and flags | `clonetree --help` or `clonetree <command> --help` |
235
+ | Allocation benchmarks and implementation performance | [Performance notes](PERFORMANCE.md) |
236
+ | Native APFS tests and XFS/Btrfs tests in Ubuntu Docker or a VM | [Testing](TESTING.md) |
237
+ | Logo and social-preview artwork | [Brand assets](docs/BRANDING.md) |
238
+
239
+ Licensed under [MPL 2.0](LICENSE).
Binary file
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "cpu": [
7
7
  "x64"
8
8
  ],
9
- "description": "Like git worktrees but doesn't use up your disk space. Uses clones instead of copy (aka copy-on-write). Fast worktrees for monorepos.",
9
+ "description": "Worktrees that are friendly to your disk space. Uses clones instead of copy (aka copy-on-write). Fast worktrees for monorepos.",
10
10
  "files": [
11
11
  "README.md",
12
12
  "LICENSE",
@@ -33,5 +33,5 @@
33
33
  "type": "git",
34
34
  "url": "git+https://github.com/sprisa/clonetree.git"
35
35
  },
36
- "version": "0.1.0"
36
+ "version": "1.0.1"
37
37
  }