git.show
Synopsis
git.show <repo> <revision> [name: value]...
Description
Shows each object named by revision and revs, in that order. A commit is
shown as a commit record followed by one hunk record per change against
its first parent, with renamed files detected as git show detects them; a
root commit is compared with the empty tree.
A merge is shown with the condensed combined difference of git show
(--cc): only files that differ from every parent are considered, each line
carries one prefix column per parent, and a group of changes is left out when
the parents hold at most two versions of it and the merge takes one of them
unchanged. A merge that only takes changes from its parents therefore shows
no hunks. The old_start and old_len fields of a combined hunk give the
lines of the first parent.
An annotated tag is shown as a git_tag record followed by the object it
tags; tags of tags are followed to the end. A revision that names a tree or a
file is rejected; the content of a file is read with file.
With file, the content of the file at the commit of revision is returned
as one content record. offset and limit select lines; the content is
read as stored in the repository, without conversion filters. Binary content
is reported without text.
A change without line differences, such as a change of mode or an exact
rename, is one hunk without lines. A binary change is one hunk with
binary: true and no lines.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
repo |
path |
required | Repository or path inside it. |
revision |
text |
required | Revision to show. |
revs |
list<text> |
none | Further revisions to show. |
file |
path |
none | Return the content of this file at the revision. |
paths |
list<path> |
none | Only changes in these files or directories. |
offset |
int |
none | First line of the file content returned, counted from 1. |
limit |
int |
none | Maximum number of lines of the file content returned. |
stat |
bool |
false |
Only changed files with added and removed lines. |
context |
int |
3 |
Lines of context around each change. |
exclude |
list<glob> |
[] |
Paths to leave out; the report counts the excluded files. |
Input and output
| Form | Input | Output |
|---|---|---|
| default | none |
commit, hunk, git_tag, content |
Effect
| Property | Value |
|---|---|
| Category | source |
| Effect | read |
| Reversibility | read |
| Implementation | builtin |
| External use | user_program: gpg; Runs gpg (gpg.openpgp.program or gpg.program) to verify OpenPGP signatures when the signature field of the commits or tags is selected. |
Examples
Show the last commit with its changes.
git.show "/home/user/repo" "HEAD"
commit short_id: 4f2a9c1 subject: "fix(parser): accept empty input"
hunk path: src/parser.rs old_start: 41 old_len: 6 new_start: 41 new_len: 8 header: "fn parse(input: &str) -> Result<Ast> {"
Show the files changed by a merge against its first parent.
git.show "/home/user/repo" "HEAD" stat: true
Show a release tag and the commit it tags, without lock files.
git.show "/home/user/repo" "v1.4.0" exclude: ["*.lock"]
Read lines 100 to 149 of a file as it was two commits ago.
git.show "/home/user/repo" "HEAD~2" file: "/home/user/repo/src/main.rs" offset: 100 limit: 50
Errors
| Code | Meaning | Typical fix |
|---|---|---|
E_GIT_NOT_REPOSITORY |
repo is not inside a repository, or a path is outside it (problem path_outside_repo). |
Give a path inside the working tree |
E_GIT_REVISION |
A revision is unknown, ambiguous, a range (range), or names a tree or a file (not_a_commit). |
Give a commit or a tag; read files with file |
E_NOT_FOUND |
file does not exist at the revision. |
Find the commits of the file with git.log |
E_INVALID_VALUE |
file names a directory or a submodule, file with revs, paths or stat, offset or limit without file, or offset: 0. |
Remove the conflicting argument |
E_TYPE |
exclude is not a list of patterns. |
Give glob patterns |
E_IO |
An object of the repository cannot be read. | Check the repository with git.status |
Related
git.log, git.diff, git.blame, git.tag.