@@ -25,6 +25,41 @@ git-sync can also be configured to make a webhook call or exec a command upon
25
25
successful git repo synchronization. The call is made after the symlink is
26
26
updated.
27
27
28
+ ## What it produces and why - the contract
29
+
30
+ git-sync has two required flags: ` --repo ` , which specifies which remote git
31
+ repo to sync, and ` --root ` which specifies a working directory for git-sync,
32
+ which presents an "API" of sorts.
33
+
34
+ The ` --root ` directory is _ not_ the synced data.
35
+
36
+ Inside the ` --root ` directory git-sync stores the synced git state and other
37
+ things. That directory may or may not respond to git commands - it's an
38
+ implementation detail.
39
+
40
+ One of the things in that directory is a symlink (see the ` --link ` flag) to the
41
+ most recently synced data. This is how the data is expected to be consumed,
42
+ and is considered to be the "contract" between git-sync and consumers. The
43
+ exact target of that symlink is an implementation detail, but the leaf
44
+ component of the target (i.e. ` basename "$(readlink <link>)" ` ) is the git hash
45
+ of the synced revision. This is also part of the contract.
46
+
47
+ git-sync looks for changes in the remote repo periodically (see the ` --period `
48
+ flag) and will attempt to transfer as little data as possible and use as little
49
+ disk space as possible (see the ` --depth ` and ` --git-gc ` flags), but this is
50
+ not part of the contract.
51
+
52
+ ### Why the symlink?
53
+
54
+ git checkouts are not "atomic" operations. If you look at the repository while
55
+ a checkout is happening, you might see data that is neither exactly the old
56
+ revision nor the new. git-sync "publishes" updates via the symlink to present
57
+ an atomic interface to consumers. When the remote repo has changed, git-sync
58
+ will fetch the data _ without_ checking it out, then create a new worktree, then
59
+ change the symlink to point to that new worktree.
60
+
61
+ git-sync does not currently have a no-symlink mode.
62
+
28
63
## Major update: v3.x -> v4.x
29
64
30
65
git-sync has undergone many significant changes between v3.x and v4.x. [ See
@@ -139,6 +174,38 @@ DESCRIPTION
139
174
git-sync can also be configured to make a webhook call upon successful git
140
175
repo synchronization. The call is made after the symlink is updated.
141
176
177
+ CONTRACT
178
+
179
+ git-sync has two required flags:
180
+ --repo: specifies which remote git repo to sync
181
+ --root: specifies a working directory for git-sync
182
+
183
+ The root directory is not the synced data.
184
+
185
+ Inside the root directory, git-sync stores the synced git state and other
186
+ things. That directory may or may not respond to git commands - it's an
187
+ implementation detail.
188
+
189
+ One of the things in that directory is a symlink (see the --link flag) to
190
+ the most recently synced data. This is how the data is expected to be
191
+ consumed, and is considered to be the "contract" between git-sync and
192
+ consumers. The exact target of that symlink is an implementation detail,
193
+ but the leaf component of the target (i.e. basename "$(readlink <link>)")
194
+ is the git hash of the synced revision. This is also part of the contract.
195
+
196
+ Why the symlink? git checkouts are not "atomic" operations. If you look
197
+ at the repository while a checkout is happening, you might see data that is
198
+ neither exactly the old revision nor the new. git-sync "publishes" updates
199
+ via the symlink to present an atomic interface to consumers. When the
200
+ remote repo has changed, git-sync will fetch the data _without_ checking it
201
+ out, then create a new worktree, then change the symlink to point to that
202
+ new worktree.
203
+
204
+ git-sync looks for changes in the remote repo periodically (see the
205
+ --period flag) and will attempt to transfer as little data as possible and
206
+ use as little disk space as possible (see the --depth and --git-gc flags),
207
+ but this is not part of the contract.
208
+
142
209
OPTIONS
143
210
144
211
Many options can be specified as either a commandline flag or an environment
0 commit comments