Skip to content

Commit adcb3d1

Browse files
committed
bundles: add 'bundle.heuristic' to bundle list
Include the 'bundle.heuristic' config (value "creationToken" to denote use of the creation token heuristic [1]) in the bundle list. Without this, Git will not use the creation token heuristic to apply incremental bundle updates on fetches after an initial clone. Signed-off-by: Victoria Dye <[email protected]>
1 parent 62f35ce commit adcb3d1

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

internal/bundles/bundles.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,19 @@ func NewBundle(repo *core.Repository, timestamp int64) Bundle {
5959
}
6060

6161
type BundleList struct {
62-
Version int
63-
Mode string
64-
Bundles map[int64]Bundle
62+
Version int
63+
Mode string
64+
Heuristic string
65+
Bundles map[int64]Bundle
66+
}
67+
68+
func NewBundleList() *BundleList {
69+
return &BundleList{
70+
Version: 1,
71+
Mode: "any",
72+
Heuristic: "creationToken",
73+
Bundles: make(map[int64]Bundle),
74+
}
6575
}
6676

6777
func (list *BundleList) addBundle(bundle Bundle) {
@@ -125,11 +135,9 @@ func (b *bundleProvider) createDistinctBundle(repo *core.Repository, list *Bundl
125135
}
126136

127137
func (b *bundleProvider) CreateSingletonList(ctx context.Context, bundle Bundle) *BundleList {
128-
list := BundleList{1, "all", make(map[int64]Bundle)}
129-
138+
list := NewBundleList()
130139
list.addBundle(bundle)
131-
132-
return &list
140+
return list
133141
}
134142

135143
// Given a BundleList, write the bundle list content to the web directory.
@@ -161,8 +169,8 @@ func (b *bundleProvider) WriteBundleList(ctx context.Context, list *BundleList,
161169
defer out.Flush()
162170

163171
fmt.Fprintf(
164-
out, "[bundle]\n\tversion = %d\n\tmode = %s\n\n",
165-
list.Version, list.Mode)
172+
out, "[bundle]\n\tversion = %d\n\tmode = %s\n\theuristic = %s\n\n",
173+
list.Version, list.Mode, list.Heuristic)
166174

167175
uriBase := path.Dir(requestUri) + "/"
168176
for _, token := range keys {

0 commit comments

Comments
 (0)