On this page
Holds the per-feature git version floors, so a command needing a newer git refuses by name and says what to upgrade to, instead of a raw error from git.
#internal/gitversion
#internal/gitversion
Package gitversion parses the installed git's version and compares it against the per-feature floors safegit depends on.
Every git capability safegit uses that is not ancient is declared here as a Feature with the git version that introduced it. A command that needs one calls Require, which produces an error naming both the feature and its floor, so an operator on an older git is told what to upgrade to and why -- never handed a raw "unknown option" from git.
#MergeTreeWriteTree
var MergeTreeWriteTree = Feature{MergeTreeWriteTree is the real merge engine: computing a merge into an object store without touching the index or the worktree.
#AttrSource
var AttrSource = Feature{AttrSource lets attribute lookups come from a tree instead of the worktree, which is what makes a worktree-free merge honor .gitattributes.
#MergeTreeStrategyOption
var MergeTreeStrategyOption = Feature{MergeTreeStrategyOption is -X on the merge engine: tuning how the merge resolves, the way git merge -X does. git's own release note for it reads "git merge-tree" learned to take strategy backend specific options via the "-X" option, like "git merge" does.
#Version
type Version structVersion is a git version, compared major-then-minor-then-patch. Trailing vendor suffixes git appends on some platforms ("2.39.5 (Apple Git-154)", "2.42.0.windows.2") are not part of the ordering.
#Feature
type Feature structFeature is a git capability with the version that introduced it.
#Parse
func Parse(s string) (Version, error)Parse reads a version out of git --version output ("git version 2.43.0") or a bare version string ("2.43.0", "2.39"). An absent patch component reads as 0. Anything after the numeric components is ignored, so vendor suffixes do not make a version unparseable.
#Features
func Features() []FeatureFeatures returns every declared feature floor.
#HighestFloor
func HighestFloor() FeatureHighestFloor returns the feature with the newest floor: the git version that makes every safegit feature available.
#Require
func Require(have Version, f Feature) errorRequire returns nil when have satisfies f's floor, and an error naming the feature, the floor and the version actually found otherwise.
#Version.String
func (v Version) String() string#Version.Compare
func (v Version) Compare(o Version) intCompare returns -1, 0 or 1 as v sorts before, equal to, or after o.
#Version.AtLeast
func (v Version) AtLeast(o Version) bool { return v.Compare(o) >= 0 }AtLeast reports whether v is o or newer.
#Version.Before
func (v Version) Before(o Version) bool { return v.Compare(o) < 0 }Before reports whether v is older than o.