@@ -81,3 +81,103 @@ repository and configured future fetches, the latter to [fetch new
81
81
bundles] [ bundle-uri-fetch ] according to the ` creationToken ` heuristic.
82
82
83
83
[ bundle-uri-fetch ] : https://git-scm.com/docs/bundle-uri#_fetching_with_bundle_uris
84
+
85
+ ## Use with ` git `
86
+
87
+ Although the contents of the bundle server can be downloaded manually, the
88
+ intended use case of the bundle server is to supplement clones & fetches in Git.
89
+
90
+ ### ` git clone `
91
+
92
+ When performing an initial clone from a remote repository, the ` --bundle-uri `
93
+ option can be specified to download an initial list of bundles _ as well as_
94
+ configure future fetches to download incremental updates from the bundle server.
95
+
96
+ Within Git, this process is as follows:
97
+
98
+ ``` mermaid
99
+ %%{ init: { 'flowchart': { 'curve': 'monotoneX' } } }%%
100
+ flowchart TB;
101
+ user((User))
102
+ subgraph git
103
+ direction TB
104
+
105
+ req["Request to --bundle-uri URI"]
106
+ isBundle{{"Is response a bundle?"}}
107
+ unbundle["Unbundle response"]
108
+ parse["Parse bundle list"]
109
+ sort["Sort bundles by creationToken,\nhigh to low, select bundle with\nhighest creationToken"]
110
+ reqBundle["Request bundle from server"]
111
+ markUnbundled["Mark unbundled to\nskip it later"]
112
+ downloadSuccess{{"Download successful?"}}
113
+ unbundleReq["Unbundle downloaded bundle"]
114
+ reachable{{"All bundle objects are reachable?"}}
115
+ moreBundles{{"More bundles in list?"}}
116
+ moveLater["Select bundle list item with\nlower creationToken"]
117
+ moveEarlier["Select not-yet-unbundled\nbundle list item with\nhigher creationToken"]
118
+ incrementalFetch["Incremental fetch from origin"]
119
+ end
120
+ bundleServer[(Bundle Server)]
121
+ origin[(Remote host)]
122
+
123
+ user --> |"git clone --bundle-uri URI"| req
124
+ req <--> bundleServer
125
+ req --> isBundle
126
+ isBundle ----------> |Yes| unbundle
127
+ unbundle ---> incrementalFetch
128
+
129
+ isBundle --> |No| parse
130
+ parse --> sort
131
+ sort --> reqBundle
132
+ reqBundle <--> bundleServer
133
+ reqBundle --> downloadSuccess
134
+ downloadSuccess --> |Yes| unbundleReq
135
+ moreBundles ----> |No| incrementalFetch
136
+ moreBundles ---> |Yes| moveLater
137
+ downloadSuccess --> |No| markUnbundled
138
+ markUnbundled --> moveLater
139
+ unbundleReq --> reachable
140
+ reachable --> |No| moreBundles
141
+ reachable --> |Yes| moveEarlier
142
+ moveEarlier --> |No| unbundleReq
143
+ moveLater --> reqBundle
144
+
145
+ incrementalFetch <--> origin
146
+
147
+ ```
148
+
149
+ ### ` git fetch `
150
+
151
+ The process for fetching with a bundle server is very similar to that of
152
+ cloning. Instead of a ` --bundle-uri ` , ` git fetch ` will use the ` fetch.bundleURI `
153
+ (set by an earlier ` clone ` ) as its base bundle URI, as well as a stored
154
+ ` fetch.bundleCreationToken ` indicating that bundles with a ` creationToken ` less
155
+ than the stored value should not be (re-)fetched.
156
+
157
+ In the flowchart above, this corresponds to an additional decision point:
158
+
159
+ ``` mermaid
160
+ %%{ init: { 'flowchart': { 'curve': 'monotoneX' } } }%%
161
+ flowchart TB;
162
+ user((User))
163
+ subgraph git
164
+ direction TB
165
+
166
+ reqBundle["Request bundle from server"]
167
+ moreBundles{{"More bundles in list?"}}
168
+ moveLater["Select bundle list item with\nlower creationToken"]
169
+ creationToken{{"creationToken >= fetch.bundleCreationToken?"}}
170
+ style creationToken fill:#007733,stroke:#333,stroke-width:4px
171
+ incrementalFetch["Incremental fetch from origin"]
172
+ end
173
+ origin[(Remote host)]
174
+
175
+ user -.-> reqBundle
176
+ reqBundle -....-> moreBundles
177
+ moreBundles --> |No| incrementalFetch
178
+ moreBundles --> |Yes| moveLater
179
+ moveLater --> creationToken
180
+ creationToken --> |Yes| reqBundle
181
+ creationToken --> |No| incrementalFetch
182
+ incrementalFetch <--> origin
183
+ ```
0 commit comments