Skip to content

Git

Index

git::is_git_repo

Return true if the given path is inside a git repository (work tree, bare repo, or .git dir).

Arguments

  • $1 (dir): path

git::assert_git_repo

Die if the given path is not inside a git repository.

Arguments

  • $1 (dir): path

Exit codes

  • 0: if true
  • 1: if false

git::repo_root

Resolve the toplevel (work-tree root) of the repo containing the given dir. Validates the path is a git repo first. Dies if not.

Arguments

  • $1 (dir): path inside a git repo

Output on stdout

  • absolute path of the repo's toplevel

git::canonical_name

Get the configured user.name for the given repo. Dies if unset or empty. Resolution follows the standard git config chain (local > global > system).

Arguments

  • $1 (repo): path inside a git repo

Output on stdout

  • the configured user.name

git::canonical_email

Get the configured user.email for the given repo. Dies if unset or empty. Resolution follows the standard git config chain (local > global > system).

Arguments

  • $1 (repo): path inside a git repo

Output on stdout

  • the configured user.email

git::write_distinct_identities

Write distinct identities (union of author and committer) from every commit reachable via --all to out_file. One identity per line, tab-separated as: nameemail. Sorted, deduped. Dies if the repo has no commits.

Arguments

  • $1 (repo): path inside a git repo
  • $2 (out_file): destination file (overwritten)

git::print_identities

Pretty-print identities from a tab-separated nameemail file as bullet list to stderr. Emits prefix_msg via log::log, then one ' name ' line per file row.

Arguments

  • $1 (prefix_msg): log line printed before the bullets
  • $2 (file): path to identities file (tab-separated nameemail)

git::prompt_select_identities

Interactively prompt the user for each identity in distinct_file. Each accepted identity is appended (verbatim) to selected_file. selected_file is truncated on entry. distinct_file is read via FD 3 so the prompt's stdin is preserved. The prompt defaults to YES (prompt::yn) for identities whose name shares a whitespace-separated token with canonical_name (case-insensitive, alphanumeric-word match — so canonical 'Rick Venutolo' matches identities like 'Rick Venutolo' or 'Venutolo, Rick'); otherwise it defaults to NO (prompt::ny). An empty canonical_name disables smart defaulting (always default-no).

Arguments

  • $1 (distinct_file): source file (tab-separated nameemail rows)
  • $2 (selected_file): destination file for picked rows (overwritten then appended)
  • $3 (canonical_name): name used to derive default-yes tokens (may be empty)

git::count_author_matches

Count commits across --all whose author identity (nameemail) matches any line in selected_file. Output is a single integer.

Arguments

  • $1 (repo): path inside a git repo
  • $2 (selected_file): tab-separated nameemail file

Output on stdout

  • match count (integer)

git::count_committer_matches

Count commits across --all whose committer identity (nameemail) matches any line in selected_file. Output is a single integer.

Arguments

  • $1 (repo): path inside a git repo
  • $2 (selected_file): tab-separated nameemail file

Output on stdout

  • match count (integer)

git::count_author_or_committer_matches

Count commits across --all whose author OR committer identity (nameemail) matches any line in selected_file. A commit where both author and committer match is counted once, not twice. Output is a single integer.

Arguments

  • $1 (repo): path inside a git repo
  • $2 (selected_file): tab-separated nameemail file

Output on stdout

  • match count (integer)

git::resolve_filter_repo_cmd

Populate the named array with the command (and any leading args) to invoke git-filter-repo. Prefers the local binary; falls back to running it via nix run from nixpkgs-unstable. Dies if neither git-filter-repo nor nix is on PATH.

Arguments

  • $1 (array_name): name of an existing array variable to populate (via nameref)