Fast implementation of Git in pure Go codeberg.org/lindenii/furgit
git go
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

network/receivepack: Add commit-graph support

Runxi Yu 1c859e36 8c135d16

+18 -5
+5 -2
network/receivepack/hook.go
··· 4 4 "context" 5 5 "io" 6 6 7 + commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read" 7 8 "codeberg.org/lindenii/furgit/network/receivepack/service" 8 9 objectid "codeberg.org/lindenii/furgit/object/id" 9 10 objectstore "codeberg.org/lindenii/furgit/object/store" ··· 31 32 // HookRequest is the input presented to a receive-pack hook before quarantine 32 33 // promotion and ref updates. 33 34 // 34 - // Refs, ExistingObjects, and QuarantinedObjects are borrowed and are only 35 - // valid for the duration of the hook call. 35 + // Refs, ExistingObjects, QuarantinedObjects, and CommitGraph are borrowed and 36 + // are only valid for the duration of the hook call. 36 37 type HookRequest struct { 37 38 Refs refstore.ReadingStore 38 39 ExistingObjects objectstore.ReadingStore 39 40 QuarantinedObjects objectstore.ReadingStore 41 + CommitGraph *commitgraphread.Reader 40 42 Updates []RefUpdate 41 43 PushOptions []string 42 44 IO HookIO ··· 69 71 Refs: req.Refs, 70 72 ExistingObjects: req.ExistingObjects, 71 73 QuarantinedObjects: req.QuarantinedObjects, 74 + CommitGraph: req.CommitGraph, 72 75 Updates: translatedUpdates, 73 76 PushOptions: append([]string(nil), req.PushOptions...), 74 77 IO: HookIO{
+1 -1
network/receivepack/hooks/reject_force_push.go
··· 46 46 continue 47 47 } 48 48 49 - ok, err := commitquery.New(objects, nil).IsAncestor(current.ID, update.NewID) 49 + ok, err := commitquery.New(objects, req.CommitGraph).IsAncestor(current.ID, update.NewID) 50 50 if err != nil { 51 51 return nil, fmt.Errorf("check fast-forward %s: %w", update.Name, err) 52 52 }
+4
network/receivepack/options.go
··· 3 3 import ( 4 4 "os" 5 5 6 + commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read" 6 7 objectid "codeberg.org/lindenii/furgit/object/id" 7 8 objectstore "codeberg.org/lindenii/furgit/object/store" 8 9 refstore "codeberg.org/lindenii/furgit/ref/store" ··· 26 27 // ExistingObjects is the object store visible to the push before any newly 27 28 // uploaded quarantined objects are promoted. 28 29 ExistingObjects objectstore.ReadingStore 30 + // CommitGraph is an optional commit-graph snapshot corresponding to 31 + // ExistingObjects. 32 + CommitGraph *commitgraphread.Reader 29 33 // ObjectsRoot is the permanent object storage root beneath which per-push 30 34 // quarantine directories are derived. 31 35 ObjectsRoot *os.Root
+1
network/receivepack/receivepack.go
··· 111 111 Algorithm: opts.Algorithm, 112 112 Refs: opts.Refs, 113 113 ExistingObjects: opts.ExistingObjects, 114 + CommitGraph: opts.CommitGraph, 114 115 ObjectsRoot: opts.ObjectsRoot, 115 116 Progress: progressWriter, 116 117 ProgressFlush: progressFlush,
+4 -2
network/receivepack/service/hook.go
··· 4 4 "context" 5 5 "io" 6 6 7 + commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read" 7 8 objectid "codeberg.org/lindenii/furgit/object/id" 8 9 objectstore "codeberg.org/lindenii/furgit/object/store" 9 10 refstore "codeberg.org/lindenii/furgit/ref/store" ··· 27 28 28 29 // HookRequest is the borrowed view passed to one Hook invocation. 29 30 // 30 - // Refs, ExistingObjects, and QuarantinedObjects are borrowed and are only 31 - // valid for the duration of the hook call. 31 + // Refs, ExistingObjects, QuarantinedObjects, and CommitGraph are borrowed and 32 + // are only valid for the duration of the hook call. 32 33 type HookRequest struct { 33 34 Refs refstore.ReadingStore 34 35 ExistingObjects objectstore.ReadingStore 35 36 QuarantinedObjects objectstore.ReadingStore 37 + CommitGraph *commitgraphread.Reader 36 38 Updates []RefUpdate 37 39 PushOptions []string 38 40 IO HookIO
+2
network/receivepack/service/options.go
··· 5 5 "io/fs" 6 6 "os" 7 7 8 + commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read" 8 9 objectid "codeberg.org/lindenii/furgit/object/id" 9 10 objectstore "codeberg.org/lindenii/furgit/object/store" 10 11 refstore "codeberg.org/lindenii/furgit/ref/store" ··· 27 28 Algorithm objectid.Algorithm 28 29 Refs refstore.ReadWriteStore 29 30 ExistingObjects objectstore.ReadingStore 31 + CommitGraph *commitgraphread.Reader 30 32 ObjectsRoot *os.Root 31 33 Progress io.Writer 32 34 ProgressFlush func() error
+1
network/receivepack/service/run_hook.go
··· 122 122 Refs: service.opts.Refs, 123 123 ExistingObjects: service.opts.ExistingObjects, 124 124 QuarantinedObjects: quarantinedObjects, 125 + CommitGraph: service.opts.CommitGraph, 125 126 Updates: buildHookUpdates(commands), 126 127 PushOptions: append([]string(nil), req.PushOptions...), 127 128 IO: service.opts.HookIO,