reviewrefs

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package reviewrefs keeps the commits saved review versions record (head, base and merge base) in the clone for as long as the versions exist, so a git gc in the clone cannot prune what a version's lazy patches are read from. Each version gets refs under gitlocal.RetainPrefix, written right after the version is stored (Keep) and reconciled with the clone's stores by the daemon (Reconcile): refs the clone's versions lack are created, and refs of versions no store of the clone holds are deleted. Both run outside the store's transaction, so a failure never undoes a version; a commit the clone does not hold is skipped, never fetched. A symbolic ref at a retained name was not written by baum and is left alone.

Index

Constants

This section is empty.

Variables

View Source
var DefaultLimits = Limits{Check: 3000, Write: 600, Delete: 600}

DefaultLimits are the daemon's: a pass looks up commits 3000 at a time, at most 12000, and writes or deletes at most 600 refs (200 versions) each.

Functions

func Keep

func Keep(ctx context.Context, repo *gitlocal.Repo, versions *store.Store, key store.Key, m store.Metadata) error

Keep writes the refs of the version m just stored in versions under key. A ref that already names its commit is left; a commit the clone lacks is skipped. Nothing is written for a store that is not the clone's own. A write that fails because another writer got there first is no error; a symbolic ref at one of the version's names is left and reported.

Types

type Limits

type Limits struct {
	// Check is how many commits are looked up at once for refs to write; a
	// pass looks up at most checkBatches times as many.
	Check int
	// Write bounds the refs created or moved; Delete the refs deleted.
	Write, Delete int
}

Limits bound one Reconcile pass.

type Result

type Result struct {
	Written, Deleted int
	// Missing counts refs not written because the clone lacks the commit.
	Missing int
	// Symbolic counts symbolic refs at retained names, left alone.
	Symbolic int
	// Failed are the refs that could not be written or deleted even alone.
	Failed []string
	// More is set when a bound left refs to write or delete for a next pass.
	More bool
}

Result is what one Reconcile pass did.

func Reconcile

func Reconcile(ctx context.Context, repo *gitlocal.Repo, limits Limits) (Result, error)

Reconcile brings the clone's retained refs in line with the versions in its own stores (store.Roots), within limits: it creates the refs of versions that lack them, for commits the clone holds, and deletes the plain refs, under gitlocal.RetainPrefix only and only names ParseRetainRef reads, of versions no store holds. A symbolic ref is never written or deleted. A store that exists but cannot be read fails the pass before anything changes; when no store exists at all, nothing is deleted, since a store gone missing cannot be told from one moved. When a transaction fails (another writer, a name that clashes with another ref), the pass is planned once more from what is there now and applied in ever smaller transactions; the refs that cannot change even alone are Result.Failed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL