aboutsummaryrefslogtreecommitdiff
path: root/network/receivepack
diff options
context:
space:
mode:
Diffstat (limited to 'network/receivepack')
-rw-r--r--network/receivepack/hook.go7
-rw-r--r--network/receivepack/hooks/reject_force_push.go2
-rw-r--r--network/receivepack/options.go4
-rw-r--r--network/receivepack/receivepack.go1
-rw-r--r--network/receivepack/service/hook.go6
-rw-r--r--network/receivepack/service/options.go2
-rw-r--r--network/receivepack/service/run_hook.go1
7 files changed, 18 insertions, 5 deletions
diff --git a/network/receivepack/hook.go b/network/receivepack/hook.go
index 32101fa6..a9f36a9e 100644
--- a/network/receivepack/hook.go
+++ b/network/receivepack/hook.go
@@ -4,6 +4,7 @@ import (
"context"
"io"
+ commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read"
"codeberg.org/lindenii/furgit/network/receivepack/service"
objectid "codeberg.org/lindenii/furgit/object/id"
objectstore "codeberg.org/lindenii/furgit/object/store"
@@ -31,12 +32,13 @@ type UpdateDecision struct {
// HookRequest is the input presented to a receive-pack hook before quarantine
// promotion and ref updates.
//
-// Refs, ExistingObjects, and QuarantinedObjects are borrowed and are only
-// valid for the duration of the hook call.
+// Refs, ExistingObjects, QuarantinedObjects, and CommitGraph are borrowed and
+// are only valid for the duration of the hook call.
type HookRequest struct {
Refs refstore.ReadingStore
ExistingObjects objectstore.ReadingStore
QuarantinedObjects objectstore.ReadingStore
+ CommitGraph *commitgraphread.Reader
Updates []RefUpdate
PushOptions []string
IO HookIO
@@ -69,6 +71,7 @@ func translateHook(hook Hook) service.Hook {
Refs: req.Refs,
ExistingObjects: req.ExistingObjects,
QuarantinedObjects: req.QuarantinedObjects,
+ CommitGraph: req.CommitGraph,
Updates: translatedUpdates,
PushOptions: append([]string(nil), req.PushOptions...),
IO: HookIO{
diff --git a/network/receivepack/hooks/reject_force_push.go b/network/receivepack/hooks/reject_force_push.go
index b02b5ba1..762c305d 100644
--- a/network/receivepack/hooks/reject_force_push.go
+++ b/network/receivepack/hooks/reject_force_push.go
@@ -46,7 +46,7 @@ func RejectForcePush() receivepack.Hook {
continue
}
- ok, err := commitquery.New(objects, nil).IsAncestor(current.ID, update.NewID)
+ ok, err := commitquery.New(objects, req.CommitGraph).IsAncestor(current.ID, update.NewID)
if err != nil {
return nil, fmt.Errorf("check fast-forward %s: %w", update.Name, err)
}
diff --git a/network/receivepack/options.go b/network/receivepack/options.go
index 9dd57b1f..ca13c623 100644
--- a/network/receivepack/options.go
+++ b/network/receivepack/options.go
@@ -3,6 +3,7 @@ package receivepack
import (
"os"
+ commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read"
objectid "codeberg.org/lindenii/furgit/object/id"
objectstore "codeberg.org/lindenii/furgit/object/store"
refstore "codeberg.org/lindenii/furgit/ref/store"
@@ -26,6 +27,9 @@ type Options struct {
// ExistingObjects is the object store visible to the push before any newly
// uploaded quarantined objects are promoted.
ExistingObjects objectstore.ReadingStore
+ // CommitGraph is an optional commit-graph snapshot corresponding to
+ // ExistingObjects.
+ CommitGraph *commitgraphread.Reader
// ObjectsRoot is the permanent object storage root beneath which per-push
// quarantine directories are derived.
ObjectsRoot *os.Root
diff --git a/network/receivepack/receivepack.go b/network/receivepack/receivepack.go
index 4ab4962f..b6190770 100644
--- a/network/receivepack/receivepack.go
+++ b/network/receivepack/receivepack.go
@@ -111,6 +111,7 @@ func ReceivePack(
Algorithm: opts.Algorithm,
Refs: opts.Refs,
ExistingObjects: opts.ExistingObjects,
+ CommitGraph: opts.CommitGraph,
ObjectsRoot: opts.ObjectsRoot,
Progress: progressWriter,
ProgressFlush: progressFlush,
diff --git a/network/receivepack/service/hook.go b/network/receivepack/service/hook.go
index c3be2a76..e3afa375 100644
--- a/network/receivepack/service/hook.go
+++ b/network/receivepack/service/hook.go
@@ -4,6 +4,7 @@ import (
"context"
"io"
+ commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read"
objectid "codeberg.org/lindenii/furgit/object/id"
objectstore "codeberg.org/lindenii/furgit/object/store"
refstore "codeberg.org/lindenii/furgit/ref/store"
@@ -27,12 +28,13 @@ type UpdateDecision struct {
// HookRequest is the borrowed view passed to one Hook invocation.
//
-// Refs, ExistingObjects, and QuarantinedObjects are borrowed and are only
-// valid for the duration of the hook call.
+// Refs, ExistingObjects, QuarantinedObjects, and CommitGraph are borrowed and
+// are only valid for the duration of the hook call.
type HookRequest struct {
Refs refstore.ReadingStore
ExistingObjects objectstore.ReadingStore
QuarantinedObjects objectstore.ReadingStore
+ CommitGraph *commitgraphread.Reader
Updates []RefUpdate
PushOptions []string
IO HookIO
diff --git a/network/receivepack/service/options.go b/network/receivepack/service/options.go
index 783afd47..ab867bce 100644
--- a/network/receivepack/service/options.go
+++ b/network/receivepack/service/options.go
@@ -5,6 +5,7 @@ import (
"io/fs"
"os"
+ commitgraphread "codeberg.org/lindenii/furgit/format/commitgraph/read"
objectid "codeberg.org/lindenii/furgit/object/id"
objectstore "codeberg.org/lindenii/furgit/object/store"
refstore "codeberg.org/lindenii/furgit/ref/store"
@@ -27,6 +28,7 @@ type Options struct {
Algorithm objectid.Algorithm
Refs refstore.ReadWriteStore
ExistingObjects objectstore.ReadingStore
+ CommitGraph *commitgraphread.Reader
ObjectsRoot *os.Root
Progress io.Writer
ProgressFlush func() error
diff --git a/network/receivepack/service/run_hook.go b/network/receivepack/service/run_hook.go
index dbfb21f7..ce8f8b7e 100644
--- a/network/receivepack/service/run_hook.go
+++ b/network/receivepack/service/run_hook.go
@@ -122,6 +122,7 @@ func (service *Service) runHook(
Refs: service.opts.Refs,
ExistingObjects: service.opts.ExistingObjects,
QuarantinedObjects: quarantinedObjects,
+ CommitGraph: service.opts.CommitGraph,
Updates: buildHookUpdates(commands),
PushOptions: append([]string(nil), req.PushOptions...),
IO: service.opts.HookIO,