.. index:: single: git_protocol .. _git_protocol/0: .. rst-class:: right **protocol** ``git_protocol`` ================ Predicates for accessing a git project current branch and latest commit data. | **Availability:** | ``logtalk_load(git(loader))`` | **Author:** Paulo Moura | **Version:** 1:3:0 | **Date:** 2026-10-23 | **Compilation flags:** | ``static`` | **Dependencies:** | (none) | **Remarks:** | (none) | **Inherited public predicates:** | (none) .. contents:: :local: :backlinks: top Public predicates ----------------- .. index:: branch/2 .. _git_protocol/0::branch/2: ``branch/2`` ^^^^^^^^^^^^ Returns the name of the current git branch. Fails if the directory is not a git repo or a sub-directory of a git repo directory. | **Compilation flags:** | ``static`` | **Template:** | ``branch(Directory,Branch)`` | **Mode and number of proofs:** | ``branch(+atom,?atom)`` - ``zero_or_one`` ------------ .. index:: root/2 .. _git_protocol/0::root/2: ``root/2`` ^^^^^^^^^^ Returns the absolute file path for the git repo root. Fails if the directory is not a git repo or a sub-directory of a git repo directory. | **Compilation flags:** | ``static`` | **Template:** | ``root(Directory,Root)`` | **Mode and number of proofs:** | ``root(+atom,?atom)`` - ``zero_or_one`` ------------ .. index:: remote/3 .. _git_protocol/0::remote/3: ``remote/3`` ^^^^^^^^^^^^ Returns the git repo remote URI. Fails if the directory is not a git repo or a sub-directory of a git repo directory. | **Compilation flags:** | ``static`` | **Template:** | ``remote(Directory,Remote,URI)`` | **Mode and number of proofs:** | ``remote(+atom,+atom,?atom)`` - ``zero_or_one`` ------------ .. index:: working_tree_clean/1 .. _git_protocol/0::working_tree_clean/1: ``working_tree_clean/1`` ^^^^^^^^^^^^^^^^^^^^^^^^ Succeeds if tracked files have no staged or unstaged changes, including submodule changes. Untracked files are ignored. Fails if ``git status`` fails. | **Compilation flags:** | ``static`` | **Template:** | ``working_tree_clean(Directory)`` | **Mode and number of proofs:** | ``working_tree_clean(+atom)`` - ``zero_or_one`` ------------ .. index:: working_tree_status/2 .. _git_protocol/0::working_tree_status/2: ``working_tree_status/2`` ^^^^^^^^^^^^^^^^^^^^^^^^^ Returns ``git status`` porcelain version 1 output for tracked changes, including submodule changes. Untracked files are ignored. Fails if ``git status`` fails. | **Compilation flags:** | ``static`` | **Template:** | ``working_tree_status(Directory,Status)`` | **Mode and number of proofs:** | ``working_tree_status(+atom,-atom)`` - ``zero_or_one`` ------------ .. index:: commit_author/2 .. _git_protocol/0::commit_author/2: ``commit_author/2`` ^^^^^^^^^^^^^^^^^^^ Returns the latest commit author. Fails if the directory is not a git repo or a sub-directory of a git repo directory. | **Compilation flags:** | ``static`` | **Template:** | ``commit_author(Directory,Author)`` | **Mode and number of proofs:** | ``commit_author(+atom,-atom)`` - ``zero_or_one`` ------------ .. index:: commit_date/2 .. _git_protocol/0::commit_date/2: ``commit_date/2`` ^^^^^^^^^^^^^^^^^ Returns the latest commit date (strict ISO 8601 format). Fails if the directory is not a git repo or a sub-directory of a git repo directory. | **Compilation flags:** | ``static`` | **Template:** | ``commit_date(Directory,Date)`` | **Mode and number of proofs:** | ``commit_date(+atom,-atom)`` - ``zero_or_one`` ------------ .. index:: commit_hash/2 .. _git_protocol/0::commit_hash/2: ``commit_hash/2`` ^^^^^^^^^^^^^^^^^ Returns the latest commit hash. Fails if the directory is not a git repo or a sub-directory of a git repo directory. | **Compilation flags:** | ``static`` | **Template:** | ``commit_hash(Directory,Hash)`` | **Mode and number of proofs:** | ``commit_hash(+atom,-atom)`` - ``zero_or_one`` ------------ .. index:: commit_hash_abbreviated/2 .. _git_protocol/0::commit_hash_abbreviated/2: ``commit_hash_abbreviated/2`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Returns the latest commit abbreviated hash. Fails if the directory is not a git repo or a sub-directory of a git repo directory. | **Compilation flags:** | ``static`` | **Template:** | ``commit_hash_abbreviated(Directory,Hash)`` | **Mode and number of proofs:** | ``commit_hash_abbreviated(+atom,-atom)`` - ``zero_or_one`` ------------ .. index:: commit_message/2 .. _git_protocol/0::commit_message/2: ``commit_message/2`` ^^^^^^^^^^^^^^^^^^^^ Returns the latest commit message. Fails if the directory is not a git repo or a sub-directory of a git repo directory. | **Compilation flags:** | ``static`` | **Template:** | ``commit_message(Directory,Message)`` | **Mode and number of proofs:** | ``commit_message(+atom,-atom)`` - ``zero_or_one`` ------------ .. index:: commit_log/3 .. _git_protocol/0::commit_log/3: ``commit_log/3`` ^^^^^^^^^^^^^^^^ Returns the git latest commit log output for the given format (see e.g. https://git-scm.com/docs/pretty-formats). Fails if the directory is not a git repo or a sub-directory of a git repo directory. | **Compilation flags:** | ``static`` | **Template:** | ``commit_log(Directory,Format,Output)`` | **Mode and number of proofs:** | ``commit_log(+atom,+atom,-atom)`` - ``zero_or_one`` ------------ Protected predicates -------------------- (none) Private predicates ------------------ (none) Operators --------- (none)