Git helpers for Bash commands that need lightweight repository inspection or update behavior.
Source lib/bash/std/lib_std.sh before this library so logging and shared error handling are available.
git_update_repoUpdate a repository on its detected default branch, optionally allowing tracked changes in one specific path.git_get_current_branchReturn the current branch name through a caller-provided variable, ordetached head.check_script_up_to_dateCheck whether a tracked script appears current relative to its configured upstream.
_git_only_path_dirtyInternal predicate used bygit_update_repowhen an allowed dirty path is provided.
source "/absolute/path/to/lib/bash/std/lib_std.sh"
source "/absolute/path/to/lib/bash/git/lib_git.sh"
branch=""
git_get_current_branch "$PWD" branch
log_info "Current branch: $branch"git_update_repoonly attempts updates when the checked-out branch is the detected default branch, or an explicit expected branch passed by the caller.git_update_reporetriesgit pull --ff-onlytwice by default. SetBASE_GIT_PULL_MAX_ATTEMPTSto a positive integer to change the retry count.git_get_current_branchusesgit -Cso it does not change the caller's working directory or directory stack. Missing directories and non-Git directories return success with an empty result variable.git_update_repochanges into the target repository while it runs because its submodule update sequence depends on repository-relative execution.check_script_up_to_datetreats missing git state, untracked scripts, or missing upstreams as skip conditions rather than hard failures.check_script_up_to_date <script>comparesHEADwith the local remote-tracking upstream ref. It does not fetch by default, so the result reflects the freshness of local refs.check_script_up_to_date --fetch <script>runsgit fetch --quietfirst, then compares against the refreshed upstream ref. If fetch fails, the helper logs a warning and falls back to local remote-tracking refs.
BATS coverage lives in tests/lib_git.bats.