libra show

Command reference for `libra show`

Show a commit, tag, tree, blob, or the blob referenced by REV:path.

--diff-filter=[ACDMRTUXB*]

Restrict the shown files to those whose status matches the filter letters; a lowercase letter excludes that status, and a commit whose files all fail the filter prints nothing (no header, no patch). The filter is applied through the shared diff engine, so it agrees with libra diff --diff-filter, and an unknown letter is LBR-CLI-002.

libra show --diff-filter=M --name-status HEAD
libra show --diff-filter=A HEAD

--textconv / --no-textconv

Commit diffs run diff.<driver>.textconv filters by default (drivers come from .gitattributes), so show prints the converted view like Git. --textconv states that default explicitly and --no-textconv disables it (the later flag wins); both delegate to the shared diff engine, so the body matches libra diff with the same option. A failing or missing filter fails closed as LBR-IO-001.

libra show --textconv HEAD
libra show --no-textconv HEAD

--color-moved[=<mode>] / --color-moved-ws=<modes>

show colours moved lines like libra diff --color-moved (removed side bold magenta, added side bold cyan); --no-color-moved countermands an earlier flag and the later one wins, and --color-moved-ws selects the whitespace rules used while matching moved lines. Colouring is a post-processing step, so it composes with --word-diff/--color-words and the diff section stays byte-identical to libra diff with the same options.

libra show --color=always --color-moved HEAD
libra show --color=always --color-moved --word-diff HEAD

--word-diff[=<mode>] / --word-diff-regex / --color-words

show renders its patch body as a word-level diff with the same options as libra log -p: plain by default, porcelain/color/none modes, an explicit --word-diff-regex=<re>, and the coloured --color-words[=<re>] shorthand (which wins over --word-diff=plain). All reuse the shared diff renderer, so the bytes match libra diff; an invalid mode is LBR-CLI-002.

libra show --word-diff HEAD
libra show --color=always --color-words HEAD

--patience / --anchored=<text>

--patience renders the patch with the patience diff algorithm and --anchored=<text> anchors hunks on lines containing TEXT. Both are forwarded to the shared libra diff engine, so the patch body matches libra diff --patience / --anchored=<text> for the same commit.

libra show --patience HEAD
libra show --anchored=keep HEAD

Synopsis

libra show [OPTIONS] [OBJECT] [-- <PATHS>...]

Description

libra show resolves a single object reference and renders its contents. The default target is HEAD. It understands commit-ish references (HEAD~2, branch names, tag names), raw SHA-1 hashes, and the REV:path syntax for extracting a specific blob from a tree at a given revision.

For commits the output includes the header (author, committer, date, message) followed by a unified diff (the "patch"). Flags such as --no-patch, --stat, and --name-only control how much diff context is shown. For annotated tags the tagger metadata and message are printed, followed by the target object. Trees list their entries and blobs print their text content (or a binary summary).

When stdout is piped and the downstream command exits early, libra show exits quietly without printing panic/backtrace or Broken pipe diagnostics.

Default layout

The default header keeps the blank line between the Date: line and the indented commit message. --oneline, --pretty, and --format are last-one-wins.

Tree objects

libra show <tree-ish> accepts a tree id, <rev>^{tree}, or <rev>:<dir> and prints Git's short tree form: tree <name as given>, a blank line, then one entry name per line in tree order. Subtrees carry a trailing / (dir1/); the listing is not recursive. --json keeps the richer {mode, object_type, hash, name} entry schema.

libra show 'HEAD^{tree}'
libra show HEAD:dir1
libra show <tree-oid>

With --pretty=format:<template> / --format=format:<template> the rendered template is the whole payload when no patch or stat follows (--no-patch), so no extra blank line is appended; when a patch or --stat block follows it, a separator newline is kept. tformat: and the named/implicit templates keep their terminating newline.

Options

Flag Short Description
<OBJECT> Object name (commit, tag, tree, blob) or <object>:<path>. Defaults to HEAD.
--no-patch -s Skip patch output and only show object metadata.
--oneline Shorthand for --pretty=oneline -- prints hash and subject on one line.
--pretty <FORMAT> Format the commit header with a preset (oneline, short, full, fuller, reference, raw) or a %-placeholder template (format:/tformat:/bare). Uses the same custom placeholders as libra log --format, including fixed signature dates %as/%ai/%ah/%cs/%ci/%ch, %b, %B, %n, ASCII/control %xNN, %%, %aI, %cI, %at, %ct, %D, %m, and color placeholders.
--format <FORMAT> Alias for --pretty=<FORMAT> (Git's --format). --oneline, --pretty, and --format are last-one-wins.
--date <FORMAT> Select the human date mode (default, short, iso, iso-strict, rfc, unix, or raw). Overrides log.date.
--abbrev-commit Abbreviate the commit object name in the default header to a 7-character prefix.
--no-abbrev-commit Show the full (unabbreviated) commit object name, countermanding an earlier --abbrev-commit (last one wins). The full hash is the default, so on its own this is a no-op.
--name-only Show only changed file names (no diff hunks).
--name-status Show changed file names prefixed by a status letter (A/M/D), tab-separated.
--raw Show the raw diff format :<old-mode> <new-mode> <old-sha> <new-sha> <status>\t<path> (object ids abbreviated to 7) instead of a patch, like git show --raw.
--stat Show the shared Git-style diffstat (per-file bar plus N files changed, X insertions(+), Y deletions(-)), identical to log --stat / diff --stat.
--patch-with-stat Show the diffstat block followed by the full patch (Git's legacy synonym for -p --stat).
--summary Show a condensed summary of created and deleted files (their mode and path), like git show --summary. Created/deleted files only — no rename/copy detection.
--no-expand-tabs Do not expand tabs in the commit message. Accepted no-op: Libra's show prints tabs verbatim.
--no-notes Do not show commit notes, countermanding an earlier --notes.
--notes[=<ref>] Show commit notes as a Notes: block (and through %N in --format). An optional =<ref> selects a notes ref; default refs/notes/commits.
--no-mailmap Do not apply a .mailmap. Accepted no-op: Libra's show shows the raw recorded identities.
--no-show-signature Do not display the GPG signature of signed commits. Accepted no-op: Libra's show never displays commit signatures inline. (Git's --show-signature is not implemented.)
<PATHS>... Limit output to matching paths (pathspec filter for commit diffs). Matches through the shared pathspec engine (plain prefixes, wildcards, and :(glob)/:(literal)/:(icase)/:(exclude)); with -- and no revision, HEAD is implied.

Examples

# Show the latest commit with full patch
libra show HEAD

# Show only metadata (no diff) for a tag
libra show --no-patch v1.0.0

# Show a specific file from a revision
libra show HEAD:src/main.rs

# Peel a revision to its tree (same expressions as rev-parse)
libra show HEAD^{tree}
libra show HEAD^{commit}

# One-line summary of a commit
libra show --oneline abc1234

# Diff statistics only
libra show --stat HEAD~1

# Limit diff to a subdirectory
libra show HEAD -- src/command/

Common Commands

libra show                          # show HEAD commit and patch
libra show HEAD~3                   # show an ancestor commit
libra show -s v2.0.0                # metadata only for a tag
libra show HEAD:Cargo.toml          # print a file at HEAD
libra show --name-only HEAD         # list changed files
libra show --name-status HEAD       # list changed files with A/M/D status
libra show --stat HEAD              # diff statistics
libra show --patch-with-stat HEAD   # diffstat followed by the full patch
libra show --summary HEAD           # created/deleted file mode summary
libra --json show HEAD              # structured JSON output

Human Output

Human mode preserves the existing presentation:

  • Commit: header plus optional patch / stat / name-only output
  • Annotated tag: tag metadata followed by the target object
  • Tree: list of tree entries
  • Blob: text content or a binary summary
  • --quiet: validates the object reference but suppresses human output
  • Human output uses the shared pager policy; pass global --no-pager to force direct stdout

Structured Output (JSON examples)

data.type determines the schema. Possible values: commit, tag, tree, blob.

Commit

{
  "ok": true,
  "command": "show",
  "data": {
    "type": "commit",
    "hash": "abc1234def5678901234567890abcdef12345678",
    "short_hash": "abc1234",
    "author_name": "Alice",
    "author_email": "alice@example.com",
    "author_date": "2026-04-01T10:00:00+00:00",
    "committer_name": "Alice",
    "committer_email": "alice@example.com",
    "committer_date": "2026-04-01T10:00:00+00:00",
    "subject": "feat: add new feature",
    "body": "",
    "parents": ["def456..."],
    "refs": ["HEAD -> main"],
    "files": [
      { "path": "tracked.txt", "status": "added" }
    ]
  }
}

Tag

{
  "ok": true,
  "command": "show",
  "data": {
    "type": "tag",
    "tag_name": "v1.0.0",
    "tagger_name": "Alice",
    "tagger_email": "alice@example.com",
    "tagger_date": "2026-04-01T10:00:00+00:00",
    "message": "Release v1.0.0",
    "target_hash": "abc1234def5678901234567890abcdef12345678",
    "target_type": "commit"
  }
}

Tree

{
  "ok": true,
  "command": "show",
  "data": {
    "type": "tree",
    "entries": [
      { "mode": "100644", "object_type": "blob", "hash": "abc123...", "name": "README.md" },
      { "mode": "040000", "object_type": "tree", "hash": "def456...", "name": "src" }
    ]
  }
}

Blob

{
  "ok": true,
  "command": "show",
  "data": {
    "type": "blob",
    "hash": "abc123...",
    "size": 1024,
    "is_binary": false,
    "content": "fn main() { ... }"
  }
}

Notes:

  • Commit JSON refs are best-effort decoration metadata; unrelated branch/tag rows no longer block show
  • Human --quiet still validates the target object but suppresses stdout and does not initialize the pager
  • Commit patch / stat paths stay strict: corrupt historical blobs fail with LBR-REPO-002 instead of falling back to working tree contents

Design Rationale

Why support REV:path syntax?

The REV:path notation (e.g., HEAD:src/main.rs) is one of the most useful idioms in Git because it lets users and tools retrieve any file at any point in history without checking out an entire commit. For AI agents this is especially valuable: an agent can read specific files at specific revisions to compare implementations across branches or time, without mutating the working tree. Libra preserves this syntax for full Git compatibility and because it maps naturally to the internal tree-walk operation that Libra already performs.

--pretty / --format and structured JSON

--pretty=<fmt> and its alias --format=<fmt> render the commit header with the oneline preset or a %-placeholder template (format:/tformat:/bare), sharing libra log's formatter. The named presets short, full, fuller, reference, and raw are rendered distinctly (matching Git's preset structure); medium maps to the default format and retains the full commit id. (This is separate from the --raw diff format — see the --raw option — which selects the raw :<old-mode> <new-mode> … diff format instead of a preset.) Without an explicit --oneline, --pretty, or --format, format.pretty supplies the human commit-header default. Likewise, log.date supplies the human date mode unless --date is present. Both keys use the strict local→global→system cascade; invalid/read-failed values stop before commit/tag output with LBR-CLI-002/LBR-IO-001. Tree, blob, REV:path, quiet validation, and structured JSON do not read these commit-display defaults. For programmatic consumers, --json remains the recommended interface: it gives every field in a well-typed, type-discriminated schema (typed fields vs. string parsing), avoiding format-string fragility.

Why type-aware JSON schema?

The data.type discriminator (commit, tag, tree, blob) means that JSON consumers can switch on the type and access only the fields that exist for that object kind. This is more ergonomic than a flat schema with many nullable fields, and it mirrors the object model of Git itself. Each variant carries exactly the fields that make sense (e.g., tagger_name appears only in tags, parents only in commits), which eliminates an entire class of "field is null but I expected it" bugs in agent tooling.

Parameter Comparison: Libra vs Git vs jj

Feature Libra Git jj
Default target HEAD HEAD N/A (jj show removed; use jj log -r @)
REV:path syntax Yes Yes No (use jj file show -r REV path)
--no-patch / -s Yes Yes N/A
--oneline Yes Yes N/A (use jj log --template)
--name-only Yes Yes N/A
--name-status Yes Yes N/A
--stat Yes Yes N/A (jj diff --stat -r REV)
--patch-with-stat Yes Yes N/A
--pretty / --format Yes (named presets + %-templates) Yes No (use templates)
--abbrev-commit Yes Yes N/A
--quiet Yes (validates only) No N/A
JSON output --json with typed schema No No
Pathspec filter Yes (trailing <PATHS>...) Yes No (use jj diff --from/--to)
Tag-aware display Auto-detects annotated tags Auto-detects annotated tags No tag objects

Error Handling

Scenario StableErrorCode Exit
Outside a repository LBR-REPO-001 128
Invalid revision or missing path LBR-CLI-003 129
Failed to read the object LBR-REPO-002 128