git.pl -- Run GIT commands
This module performs common GIT tasks by calling git as a remote process
through process_create/3. It requires that the git
executable is in the
current PATH.
This module started life in ClioPatria and has been used by the Prolog web-server to provide information on git repositories. It is now moved into the core Prolog library to support the Prolog package manager.
- git(+Argv, +Options) is det
- Run a GIT command. Defined options:
- directory(+Dir)
- Execute in the given directory
- output(-Out)
- Unify Out with a list of codes representing stdout of the
command. Otherwise the output is handed to print_message/2
with level
informational
. - error(-Error)
- As
output(Out)
, but messages are printed at levelerror
. - askpass(+Program)
- Export GIT_ASKPASS=Program
- git_process_output(+Argv, :OnOutput, +Options) is det
- Run a git-command and process the output with OnOutput, which is
called as
call(OnOutput, Stream)
. - git_open_file(+GitRepoDir, +File, +Branch, -Stream) is det
- Open the file File in the given bare GIT repository on the given branch (treeisch).
- is_git_directory(+Directory) is semidet
- True if Directory is a git directory (Either checked out or bare).
- git_describe(-Version, +Options) is semidet
- Describe the running version based on GIT tags and hashes.
Options:
- match(+Pattern)
- Only use tags that match Pattern (a Unix glob-pattern; e.g.
V*
) - directory(Dir)
- Provide the version-info for a directory that is part of a GIT-repository.
- commit(+Commit)
- Describe Commit rather than
HEAD
- git_hash(-Hash, +Options) is det
- Return the hash of the indicated object.
- git_ls_tree(-Entries, +Options) is det
- True when Entries is a list of entries in the the GIT
repository, Each entry is a term:
object(Mode, Type, Hash, Size, Name)
- git_remote_url(+Remote, -URL, +Options) is det
- URL is the remote (fetch) URL for the given Remote.
- git_ls_remote(+GitURL, -Refs, +Options) is det
- Execute
git ls-remote
against the remote repository to fetch references from the remote. Options processed:heads(Boolean)
tags(Boolean)
refs(List)
For example, to find the hash of the remote
HEAD
, one can use?- git_ls_remote('git://www.swi-prolog.org/home/pl/git/pl-devel.git', Refs, [refs(['HEAD'])]). Refs = ['5d596c52aa969d88e7959f86327f5c7ff23695f3'-'HEAD'].
- git_remote_branches(+GitURL, -Branches) is det
- Exploit git_ls_remote/3 to fetch the branches from a remote repository without downloading it.
- git_default_branch(-BranchName, +Options) is det
- True when BranchName is the default branch of a repository.
- git_branches(-Branches, +Options) is det
- True when Branches is the list of branches in the repository.
In addition to the usual options, this processes:
- contains(Commit)
- Return only branches that contain Commit.
- git_tags_on_branch(+Dir, +Branch, -Tags) is det
- Tags is a list of tags in Branch on the GIT repository Dir, most recent tag first.
- git_shortlog(+Dir, -ShortLog, +Options) is det
- Fetch information like the GitWeb change overview. Processed
options:
- limit(+Count)
- Maximum number of commits to show (default is 10)
- revisions(+Revisions)
- Git revision specification
- path(+Path)
- Only show commits that affect Path. Path is the path of a checked out file.
- git_path(+Path)
- Similar to
path
, but Path is relative to the repository.
- git_show(+Dir, +Hash, -Commit, +Options) is det
- Fetch info from a GIT commit. Options processed:
- diff(Diff)
- GIT option on how to format diffs. E.g.
stat
- max_lines(Count)
- Truncate the body at Count lines.
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.