LibraLibra
LibraLibra
DocsBlogLibra
Getting Started
Architecture
Design
Commands
libra addlibra agentlibra alternateslibra applylibra archivelibra authlibra automationlibra bisectlibra blamelibra branchlibra bundlelibra cachelibra cat-filelibra check-attrlibra check-ignorelibra check-mailmaplibra checkoutlibra cherry-picklibra cleanlibra clonelibra cloudlibra code-controllibra codelibra commit-treelibra commitlibra completionslibra configlibra credentiallibra depslibra describelibra diff-fileslibra diff-indexlibra diff-treelibra difflibra dirtylibra fast-exportlibra fast-importlibra fetchlibra filelibra for-each-reflibra format-patchlibra fscklibra gclibra graphlibra greplibra hash-objectlibra hookslibra hydratelibra index-packlibra initlibra investigatelibra layerlibra lfslibra loglibra logfilelibra loginlibra logoutlibra ls-fileslibra ls-remotelibra ls-treelibra maintenancelibra medialibra merge-baselibra merge-filelibra mergelibra metadatalibra mvlibra noteslibra oplibra openlibra pack-objectslibra packagelibra prunelibra publishlibra pulllibra pushlibra read-treelibra rebaselibra refloglibra remotelibra repacklibra replacelibra rererelibra resetlibra restorelibra rev-listlibra rev-parselibra revertlibra reviewlibra revisionlibra rmlibra sandboxlibra servicelibra shortloglibra show-reflibra showlibra sparse-viewlibra stashlibra statslibra statuslibra switchlibra symbolic-reflibra taglibra update-indexlibra update-reflibra usagelibra verify-packlibra whoamilibra worktreelibra write-tree
API Reference
Policy
Commands

libra rev-parse

Command reference for `libra rev-parse`

Parse revision names and print normalized commit IDs, symbolic refs, or repository paths.

Synopsis

libra rev-parse [OPTIONS] [SPEC]...

Description

libra rev-parse resolves a revision-like input into one of three forms:

  • the full commit ID (default)
  • a short commit ID with --short
  • a symbolic branch name with --abbrev-ref

It also supports --show-toplevel to print the absolute repository root for a working tree. When no <SPEC> is provided, the command defaults to HEAD; multiple <SPEC> arguments are each resolved on their own line. The output-filter flags (--flags/--no-flags/--revs-only/--no-revs) instead classify each argument as a flag, revision, or path and print a filtered subset.

Options

FlagDescription
--verifyAssert that <SPEC> resolves to exactly one object; print it, or exit 128 on failure (silent exit 1 under the global --quiet / -q).
--shortPrint a non-ambiguous abbreviated object ID.
--sqShell-quote the resolved object name (single-quoted) for safe shell consumption. Only affects the resolved-revision output, not query modes like --show-toplevel.
--abbrev-refPrint the symbolic branch name instead of a commit hash.
--symbolic-full-nameResolve the spec to its full ref name (refs/heads/<branch>, refs/tags/<tag>, refs/remotes/<remote>/<branch>, or HEAD when detached). A valid object that is not a ref prints nothing (exit 0); an unresolvable name fails with exit 128.
--symbolicPrint the spec in symbolic form, as close to the original input as possible: a resolvable ref, revision expression, or object id is echoed verbatim (e.g. main stays main, not refs/heads/main). An unresolvable name fails with exit 128. Mutually exclusive with --symbolic-full-name/--short/--abbrev-ref.
--flagsOutput-filter mode: classify each <SPEC> arg and print only flags (args beginning with -, before any --) and resolved revisions, dropping non-flag paths.
--no-flagsOutput-filter mode: drop flag args, keeping resolved revisions and non-flag paths.
--revs-onlyOutput-filter mode: print only the args that resolve to revisions (as object names), dropping flags and non-revision paths.
--no-revsOutput-filter mode: drop revision args, keeping flags and non-revision paths.
--show-toplevelPrint the absolute path to the top-level working tree.
--is-inside-git-dirPrint true when the current directory is inside the .libra directory (Libra's $GIT_DIR equivalent), false otherwise.
--git-dirPrint the path to the .libra directory (Libra's $GIT_DIR). In Libra this is always absolute.
--absolute-git-dirLike --git-dir, but always the canonicalized absolute path. (In Libra --git-dir is already absolute, so the two coincide.)
<SPEC>Revision to resolve. Defaults to HEAD when omitted.

Common Commands

libra rev-parse
libra rev-parse HEAD~1
libra rev-parse --short HEAD
libra rev-parse --abbrev-ref HEAD
libra rev-parse --show-toplevel
libra rev-parse --is-inside-git-dir
libra rev-parse --absolute-git-dir
libra --json rev-parse --short HEAD

Human Output

Default output is a single line containing the resolved value.

abc1234def5678901234567890abcdef12345678

With --short:

abc1234

With --abbrev-ref:

main

With --show-toplevel:

/home/alice/project

Structured Output

{
  "ok": true,
  "command": "rev-parse",
  "data": {
    "mode": "short",
    "input": "HEAD",
    "value": "abc1234"
  }
}

mode is one of resolve, short, abbrev_ref, symbolic_full_name, symbolic, show_toplevel, show_prefix, show_cdup, is_inside_work_tree, is_inside_git_dir, is_bare_repository, git_dir, or absolute_git_dir.

With a single <SPEC>, data is one such object (the shape above). With multiple <SPEC> arguments, data is a JSON array of those objects, one per spec, in order. In an output-filter mode (--flags/--no-flags/--revs-only/--no-revs), data is a JSON array of strings — the filtered tokens (resolved object names for revisions, verbatim for kept flags/paths).

Parameter Comparison: Libra vs Git vs jj

FeatureLibraGitjj
Resolve full commit IDrev-parse <spec>git rev-parse <spec>jj log -r <rev> --no-graph -T commit_id
Abbreviated commit ID--short--shortjj log -r <rev> -T change_id.short()
Symbolic branch name--abbrev-ref--abbrev-refN/A
Full ref name--symbolic-full-name--symbolic-full-nameN/A
Symbolic (verbatim) name--symbolic--symbolicN/A
Output filters--flags/--no-flags/--revs-only/--no-revssameN/A
Shell-quoted output--sq--sqN/A
Work tree root--show-toplevel--show-topleveljj root
JSON output--jsonNoNo

A -- separator splits revisions from paths in every mode (rev-parse <rev> -- <path>): arguments after -- are paths, never revisions, and the -- is echoed where path output applies. The single-revision modes --verify and --short print only the one resolved object (never the paths).

Intentional divergence from Git: combining --verify or --short with any output-filter flag (--flags/--no-flags/--revs-only/--no-revs) is rejected with a usage error (LBR-CLI-002, exit 129). Git's behavior for that combination is ill-defined, so Libra refuses it rather than guessing.

Error Handling

ScenarioStableErrorCodeExit
Invalid target refLBR-CLI-003129
--verify/--short combined with an output-filter flagLBR-CLI-002129
Invalid work tree stateLBR-REPO-003128
Failed to read repository metadataLBR-IO-001128
Corrupt stored refs/configLBR-REPO-002128

libra rev-list

Command reference for `libra rev-list`

libra revert

Command reference for `libra revert`

On this page

SynopsisDescriptionOptionsCommon CommandsHuman OutputStructured OutputParameter Comparison: Libra vs Git vs jjError Handling