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 hash-object

Command reference for `libra hash-object`

Compute the Git-compatible object ID for raw file contents or standard input.

libra hash-object [OPTIONS] <PATH>...
libra hash-object --stdin [OPTIONS]
libra hash-object --stdin-paths [OPTIONS]

It supports the four Git object types — blob (default), commit, tree, and tag — computing the object id from the <type> <size>\0<content> header using the current repository object format, byte-for-byte identical to git hash-object -t <type>. Without --literally, commit/tree/tag content is validated as a well-formed object of that type (a blob accepts any bytes). It does not apply clean filters, attributes, or LFS pointer conversion. --path is accepted as a Git compatibility path context and stdin JSON source label; it does not change the hashed bytes until path-based filters are implemented.

Read-only hashing does not require a Libra repository and defaults to SHA-1 when no repository object format is available. -w / --write requires a repository because it stores the object in the repository object database.

Options

OptionShortDescription
<PATH>...File paths to hash
--stdinRead bytes from standard input instead of file paths
--stdin-pathsRead file paths from standard input (one per line) and hash each
--write-wStore the computed object in the repository object database
--type <TYPE>-tObject type to hash: blob (default), commit, tree, or tag
--literallyHash the bytes as the given type without verifying the content is a well-formed object of that type
--path <PATH>Path context label for compatibility with Git hash-object
--no-filtersExplicitly hash raw bytes without path-based filters
--jsonEmit a structured JSON envelope
--machineEmit the same envelope as one compact JSON line

Examples

Hash a file without writing the object:

libra hash-object README.md

Hash and write a file as a blob object:

libra hash-object -w src/main.rs

Hash file content as a typed object (the id matches git hash-object -t <type>); the content is validated as a well-formed object of that type unless --literally is given:

libra hash-object -t commit commit-payload
libra hash-object -t tag --literally arbitrary-bytes

Hash bytes from standard input:

printf 'hello' | libra hash-object --stdin

Hash stdin with a Git-compatible path context label:

printf 'hello' | libra hash-object --stdin --path README.md

Output

Human output prints one object ID per input:

b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0

Structured output:

{
  "ok": true,
  "command": "hash-object",
  "data": {
    "object_type": "blob",
    "write": false,
    "objects": [
      {
        "source": "-",
        "oid": "b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0",
        "size": 5,
        "written": false
      }
    ]
  }
}

Compatibility

FeatureLibraGitJujutsu
Hash file as bloblibra hash-object <path>git hash-object <path>N/A
Read from stdin--stdin--stdinN/A
Read paths from stdin--stdin-paths--stdin-pathsN/A
Write object-w / --write-wN/A
Select object type-t blob/commit/tree/tag-t <type>N/A
Path context--path <path> accepted, no filters applied--path <path>N/A
Disable filters--no-filters accepted--no-filtersN/A
Path filters / attributesNot supportedfilters / attributesN/A
Hash literally invalid objects--literally (known types only)--literally (any type string)N/A

Errors

ConditionStable codeExitHint
Object type outside blob/commit/tree/tagLBR-CLI-002129hash-object supports blob, commit, tree, and tag
Content is not a well-formed object of -t <type> (without --literally)LBR-CLI-002129pass --literally to hash malformed content without validation
Input file cannot be readLBR-IO-001128Verify the path exists and is readable
Object cannot be writtenLBR-IO-002128Check object storage permissions and disk space

libra grep

Command reference for `libra grep`

libra hooks

Command reference for `libra hooks`

On this page

OptionsExamplesOutputCompatibilityErrors