diff options
| author | 2026-03-07 16:25:36 +0800 | |
|---|---|---|
| committer | 2026-03-07 16:43:59 +0800 | |
| commit | a0d2b3a238d6e5dcdedb816cf838dd8fe003c632 (patch) | |
| tree | 98b4026797c7e731f3ce01bd11dd102e58b116d0 /refstore/transaction.go | |
| parent | testgit: While I'm at it, add a tiny path escape hatch just for occasional use (diff) | |
| signature | No signature | |
refstore: Split files
Diffstat (limited to 'refstore/transaction.go')
| -rw-r--r-- | refstore/transaction.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/refstore/transaction.go b/refstore/transaction.go new file mode 100644 index 00000000..539229c9 --- /dev/null +++ b/refstore/transaction.go @@ -0,0 +1,43 @@ +package refstore + +import "codeberg.org/lindenii/furgit/objectid" + +// Transaction stages reference updates for one atomic commit. +// +// Ordinary methods operate in dereference mode if name resolves to +// a symbolic ref, the operation applies to the final referent rather +// than to the symbolic ref itself. +// +// Symbolic methods operate on the named reference directly, without +// dereferencing symbolic refs. +type Transaction interface { + // Create creates one detached reference, requiring that the logical + // reference does not already exist. + Create(name string, newID objectid.ObjectID) error + // Update updates one detached reference, requiring that the current logical + // reference value matches oldID. + Update(name string, newID, oldID objectid.ObjectID) error + // Delete deletes one detached reference, requiring that the current logical + // reference value matches oldID. + Delete(name string, oldID objectid.ObjectID) error + // Verify verifies that the current logical reference value matches oldID. + Verify(name string, oldID objectid.ObjectID) error + + // CreateSymbolic creates one symbolic reference, requiring that the named + // reference does not already exist. + CreateSymbolic(name, newTarget string) error + // UpdateSymbolic updates one symbolic reference directly, requiring that its + // current target matches oldTarget. + UpdateSymbolic(name, newTarget, oldTarget string) error + // DeleteSymbolic deletes one symbolic reference directly, requiring that its + // current target matches oldTarget. + DeleteSymbolic(name, oldTarget string) error + // VerifySymbolic verifies that the named symbolic reference currently points + // at oldTarget. + VerifySymbolic(name, oldTarget string) error + + // Commit validates and applies all queued operations atomically. + Commit() error + // Abort abandons the transaction and releases any resources it holds. + Abort() error +} |
