On this page
Package main is the entry point for the safegit CLI, a concurrency-safe git wrapper that isolates commits via per-invocation temporary indexes.
#safegit
#.
Package main is the entry point for the safegit CLI, a concurrency-safe git wrapper that isolates commits via per-invocation temporary indexes.
#ScrubVerifyPolicyResult
type ScrubVerifyPolicyResult structScrubVerifyPolicyResult is the per-policy result for JSON output.
#ScrubVerifyResult
type ScrubVerifyResult structScrubVerifyResult is the top-level JSON output for scrub verify.
#Recipe
type Recipe structRecipe is the raw TOML schema for a scrub recipe file.
#RecipeOperation
type RecipeOperation structRecipeOperation is a single operation within a recipe.
#ParsedRecipe
type ParsedRecipe structParsedRecipe is the validated, compiled form of a Recipe.
#RewriteAuthorResult
type RewriteAuthorResult structRewriteAuthorResult is the JSON output for rewrite-author in execute mode.
#RewriteAuthorDryRunResult
type RewriteAuthorDryRunResult structRewriteAuthorDryRunResult is the JSON output for rewrite-author --dry-run.
#RewriteMapStart
type RewriteMapStart structRewriteMapStart is the phase-"start" record.
#RewriteMapRefs
type RewriteMapRefs structRewriteMapRefs is the phase-"refs" record.
#RewriteMapComplete
type RewriteMapComplete structRewriteMapComplete is the phase-"complete" record.
#AnnotationRewriteFunc
type AnnotationRewriteFunc func(ctx context.Context, shaMap map[string]string) ([]TagRewrite, int, error)AnnotationRewriteFunc rewrites tag annotation text after refs have been updated. It receives the old-to-new SHA map for commit reference remapping and returns the tag rewrite records it produced plus the count of tags whose annotations were rewritten, so Finalize can persist and expose them.
#VerifyFunc
type VerifyFunc func(ctx context.Context) errorVerifyFunc performs command-specific post-rewrite verification (e.g., re-scanning for secrets, comparing author snapshots).
#RewriteResult
type RewriteResult structRewriteResult collects the outputs of a history rewrite so that Finalize can execute the shared post-rewrite pipeline (ref updates, cleanup, verification, oplog, push hint).
#ScanResult
type ScanResult structScanResult is the JSON output for safegit scan.
#ScanMatchJSON
type ScanMatchJSON structScanMatchJSON is a single match in JSON output.
#ScrubFileResult
type ScrubFileResult structScrubFileResult is the JSON output for scrub file in execute mode.
#ScrubFileDryRunResult
type ScrubFileDryRunResult structScrubFileDryRunResult is the JSON output for scrub file --dry-run.
#TagBodyTransformFunc
type TagBodyTransformFunc func(refname, header, body string) (newBody string, err error)TagBodyTransformFunc transforms the body of an annotated tag. It receives the tag's refname, full header text, and body text. It returns the new body (or the same body if no change is needed) and any error.
#ScrubMatchResult
type ScrubMatchResult structScrubMatchResult is the JSON output for scrub match in execute mode.
#ScrubMatchDryRunResult
type ScrubMatchDryRunResult structScrubMatchDryRunResult is the JSON output for scrub match --dry-run.
#ScrubPolicy
type ScrubPolicy structScrubPolicy records a scrub operation's pattern so that future verification can confirm the secret remains absent from the object store.
#ScrubRunResult
type ScrubRunResult structScrubRunResult is the JSON output for scrub run in execute mode.
#ScrubRunDiffEntry
type ScrubRunDiffEntry structScrubRunDiffEntry is a single blob diff in --diff preview output.
#ScrubRunDiffResult
type ScrubRunDiffResult structScrubRunDiffResult is the JSON output for scrub run --diff.
#MessageDiffEntry
type MessageDiffEntry structMessageDiffEntry is a commit message diff in --diff preview output.
#ScrubRunDryRunOpResult
type ScrubRunDryRunOpResult structScrubRunDryRunOpResult holds per-operation match counts for --dry-run output.
#ScrubRunDryRunResult
type ScrubRunDryRunResult structScrubRunDryRunResult is the JSON output for scrub run --dry-run.
#TagRewrite
type TagRewrite structTagRewrite records how a tag ref was updated during history rewriting.
#CommitTransform
type CommitTransform structCommitTransform describes how a commit should be rewritten. Zero/empty fields mean "keep the original value."
#TransformFunc
type TransformFunc func(ctx context.Context, sha string, info git.CommitInfo, remappedParents []string, shaMap map[string]string) (CommitTransform, error)TransformFunc is called for each commit during a rewrite walk. It receives the original commit SHA, its parsed info, the already-remapped parent SHAs, and the growing old-to-new SHA map (which includes identity entries for already-walked unchanged commits; transforms must treat it as read-only — the walker owns it). It returns a CommitTransform describing what (if anything) to change.
#BuildRecipeBlobContent
func BuildRecipeBlobContent(ctx context.Context, recipe *ParsedRecipe, blobSHAs []string, blobAllowedOps map[string]map[int]bool) (map[string][]byte, error)BuildRecipeBlobContent applies a parsed recipe to a set of blobs, producing a mapping from old blob SHA to modified content bytes. It reads each blob, applies recipe operations in memory, and returns only blobs whose content changed. No objects are written to the object store -- this is purely in-memory content computation for dry-run and diff use cases.
blobAllowedOps optionally restricts which operations apply to each blob. When nil, all operations apply to all blobs. When set, only operations whose index is in blobAllowedOps[blobSHA] are applied to that blob. This is used to enforce per-operation scope filters from recipe TOML files.
#RewriteResult.Finalize
func (r *RewriteResult) Finalize(ctx context.Context, flags globalFlags, cmd string, annotationRewriteFunc AnnotationRewriteFunc, verifyFunc VerifyFunc) errorFinalize runs the shared post-rewrite pipeline. The execution order is:
0. Persist the rewrite-map "start" record (commit map + pre-rewrite remote-tracking state) BEFORE any refs move, so a crash at any later step leaves the mapping recoverable 1. updateRefs — update branch and tag refs to point at rewritten commits 2. annotationRewriteFunc — rewrite tag annotation text (nil to skip) 2.5. Persist the rewrite-map "refs" record (all tag rewrites) 3. SyncMainIndexWithWorktree — sync the shared index with rewritten HEAD 4. untrackProtectedPaths — remove tracked-but-gitignored files from index 5. cleanupAfterRewrite — expire tainted reflog entries, repack, prune 6. verifyFunc — command-specific verification (nil to skip) 7. Resolve new HEAD SHA 8. Resolve current ref 8.5. Persist the rewrite-map "complete" record (new HEAD, cleanup status) 9. oplog.Append — record the operation 9.5. Append scrub policy to the untracked policy file 10. Push hint — print rlsbl-aware or default push instructions