On this page
Package repo manages the .git/safegit/ data directory including initialization, configuration loading, validation, and path helpers for all state files.
#internal/repo
#internal/repo
Package repo manages the .git/safegit/ data directory including initialization, configuration loading, validation, and path helpers for all state files.
#Config
type Config structConfig holds safegit configuration persisted in config.json.
#CommitConfig
type CommitConfig structCommitConfig holds commit-related settings.
#LockConfig
type LockConfig structLockConfig holds ref-lock acquisition settings.
#HooksConfig
type HooksConfig structHooksConfig holds hook-related settings.
#PrePrePushConfig
type PrePrePushConfig structPrePrePushConfig holds pre-pre-push hook timeout settings.
#PushConfig
type PushConfig structPushConfig holds push retry settings.
#LogConfig
type LogConfig structLogConfig holds operation log size settings.
#DefaultConfig
func DefaultConfig() ConfigDefaultConfig returns the default safegit configuration.
#SafegitDir
func SafegitDir(gitDir string) stringSafegitDir returns the path to .git/safegit/ given a .git directory path.
#SharedSafegitDir
func SharedSafegitDir(ctx context.Context, gitDir string) stringSharedSafegitDir returns the safegit directory under the common .git dir. For normal repos this is identical to SafegitDir(gitDir). For worktrees it returns
The parameter accepts either the git directory (.git) or the safegit directory (.git/safegit); callers use both forms.
#IsInitialized
func IsInitialized(gitDir string) boolIsInitialized checks whether the .git/safegit/ directory exists.
#Init
func Init(gitDir string) errorInit creates the .git/safegit/ directory structure and writes default config.json. Idempotent: returns nil if already initialized.
#EnsureInitialized
func EnsureInitialized(gitDir string) errorEnsureInitialized auto-initializes .git/safegit/ if it doesn't exist yet.
#Uninstall
func Uninstall(gitDir string) errorUninstall removes the .git/safegit/ directory entirely. In worktree setups, also cleans up the shared lock directory.
#LoadConfig
func LoadConfig(gitDir string) (*Config, error)LoadConfig reads and parses config.json from the safegit directory.
#LoadConfigFrom
func LoadConfigFrom(path string) (*Config, error)LoadConfigFrom reads and parses config from an arbitrary path.
#MarshalConfig
func MarshalConfig(cfg *Config) ([]byte, error)MarshalConfig renders the config exactly as SaveConfig would write it. It is split out so callers can mint the write as an effect instead of performing it here, which is what lets --dry-run record a config change without making one.
#ConfigPath
func ConfigPath(gitDir string) stringConfigPath is the path SaveConfig writes to for the given git dir.
#SaveConfigTo
func SaveConfigTo(path string, cfg *Config) errorSaveConfigTo writes config to an arbitrary path.
#SaveConfig
func SaveConfig(gitDir string, cfg *Config) errorSaveConfig writes config back to config.json.
#GetConfigValue
func GetConfigValue(cfg *Config, key string) (interface{}, error)GetConfigValue returns the value for a dot-separated config key.
#SetConfigValue
func SetConfigValue(cfg *Config, key, value string) errorSetConfigValue sets a dot-separated config key to the given string value.
#ValidConfigKeys
func ValidConfigKeys() []stringValidConfigKeys returns the list of supported config keys.
#Config.Validate
func (c *Config) Validate() errorValidate checks that all config values are within acceptable ranges.