Skip to content
internal/gitversion
Edit
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

Go go
var MergeTreeWriteTree = Feature{

MergeTreeWriteTree is the real merge engine: computing a merge into an object store without touching the index or the worktree.

#AttrSource

Go go
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

Go go
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

Go go
type Version struct

Version 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

Go go
type Feature struct

Feature is a git capability with the version that introduced it.

#Parse

Go go
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

Go go
func Features() []Feature

Features returns every declared feature floor.

#HighestFloor

Go go
func HighestFloor() Feature

HighestFloor returns the feature with the newest floor: the git version that makes every safegit feature available.

#Require

Go go
func Require(have Version, f Feature) error

Require returns nil when have satisfies f's floor, and an error naming the feature, the floor and the version actually found otherwise.

#Version.String

Go go
func (v Version) String() string

#Version.Compare

Go go
func (v Version) Compare(o Version) int

Compare returns -1, 0 or 1 as v sorts before, equal to, or after o.

#Version.AtLeast

Go go
func (v Version) AtLeast(o Version) bool { return v.Compare(o) >= 0 }

AtLeast reports whether v is o or newer.

#Version.Before

Go go
func (v Version) Before(o Version) bool { return v.Compare(o) < 0 }

Before reports whether v is older than o.

More tools from this site

  • claudestream Drive Claude Code from Python: run it as a subprocess and read its output as typed events, with async and sync sessions, sandbox policies, and tools you define in Python
  • claudewheel A TUI Claude Code Launcher that lets you have more than one profile, manage sessions lifecycle, pick the exact CC version, model to use (even older unlisted ones), pick which GitHub account to use, etc.
  • dirstat Fast, single-binary directory statistics CLI: every file under a tree grouped by format, with counts, sizes, and lines of code, as a colored terminal table or as JSON
  • fastware A batteries-included ASGI framework: msgspec JSON, a managed Granian server, dependency injection, SSE, WebSockets, auth, and a test client
  • go-toml-edit Zero-dep TOML editing library for Go with comment preservation
  • howmuchleft The fastest Claude Code statusline: context window, 5-hour, and weekly limit usage as three customizable gradient bars, rendering in about 6 ms
  • orxtra
  • pgdesign
  • predraw Declarative rendering pipeline: describe a scene in JSON and get SVG, PNG and WebP out, with light and dark style tokens, reusable components and text converted to path outlines
  • reposummary Turn a git repository's history into a Markdown journal: pick a time window or revision range and get a readable digest of what changed, optionally narrated by an LLM
  • rlsbl Release orchestration and project scaffolding CLI that bumps versions, validates a structured JSONL changelog, tags only the commit CI verified, and publishes to npm, PyPI, Go and more
  • saferm Command-line replacement for rm that archives every deletion with a mandatory reason and the context it ran in, so deleted files can be listed, inspected and restored
  • selfdoc Static Site Generator that builds a project's documentation site directly from its source code, so the docs can never drift from the code they describe, with SEO/AEO, first-class blog, search, and cross-project linking built in
  • strictcli
  • stricttest An always-on test-isolation floor: a pytest plugin and a Go env-hygiene module that make a test suite structurally unable to reach real credentials, the real HOME, the network, or the development repository.
  • wesktop A Python framework that turns an ASGI web app into a desktop application, serving it from a local Granian server and displaying it in a native OS window via pywebview
Search