Skip to main content

Module git_utils

Module git_utils 

Source
Expand description

Pure git plumbing shared across feature modules (sdd change binding, tool agents-md, skills config discovery, prompts paths).

Function bodies are moved verbatim from their original homes (sdd::change::git_native, skills::shared::git) so error messages stay byte-identical. Sdd-specific binding semantics (ChangeGitBinding, read/write_binding, start/attach/checkpoint flows) remain in sdd::change::git_native.

This module is a member of the top-level utility layer (future llman-core); it MUST NOT import feature modules (sdd/skills/tool/x).

Functions§

branch_diff
branch_has_upstream
current_branch
current_head_sha
effective_range_base
Effective diff-range base (git-native-v2 D1): the live merge-base of the local default branch with HEAD, the single entry point for all range semantics (locked-rule gate, specs landing, change diff/commit count, staleness). Computing it on demand means the range always covers exactly the branch’s own work and shrinks automatically after merge/rebase — no stored state, immune to unpushed accumulation. Fails when git is unavailable or no default ref exists; callers fall back to the stored base_sha (fail-open, same as the pre-v2 behavior).
find_git_root
Walk up from start looking for a .git entry (dir or worktree file).
git_common_dir
Resolve the absolute .git directory path.
git_ref_exists
is_default_branch
merge_base_sha
resolve_default_branch_ref
Resolve the default branch ref, local-first (git-native-v2 D1): local main → local masterorigin/HEAD target → origin/mainorigin/master. The local ref is the anchor for all range semantics so long-lived local work without push never drifts the base (the previous origin-first order left every change’s base at the last push position).
run_git
working_tree_clean
worktree_add
git worktree add <path> -b <branch> <base_sha> (creates and checks out).
worktree_exists
Check if a directory is already a git worktree.