libra update-index
Command reference for `libra update-index`
Modify the index directly — a focused subset of git update-index. The
companion to write-tree: --cacheinfo registers an index
entry from an object id without reading the working tree, so an index can be
built purely from objects.
Synopsis
libra update-index --add <path>...
libra update-index --remove <path>...
libra update-index --cacheinfo <mode>,<object>,<path>...Description
update-index applies, in order: every --cacheinfo entry, then the positional
paths (removed with --remove, otherwise (re)staged from the working tree), and
saves the index.
--cacheinfo <mode>,<object>,<path>inserts/updates an entry directly. The object need not exist yet (matching Git), so you can build an index from hashes computed withhash-object.<mode>is an octal file mode:100644(file),100755(executable),120000(symlink),160000(gitlink). The object id length must match the repository hash format. The path is an index key — absolute paths and..traversal are rejected.--add <path>...(re)stages files from the working tree, allowing paths not yet tracked. Without--add, a positional path must already be tracked.--remove <path>...drops the named paths from the index.
Options
| Option | Description | Example |
|---|---|---|
--add | Allow positional paths to add new (untracked) files. | libra update-index --add a.txt |
--remove | Remove the positional paths from the index. | libra update-index --remove old.txt |
--cacheinfo <mode>,<object>,<path> | Register an entry from an object id (repeatable). | libra update-index --cacheinfo 100644,<oid>,dir/f.txt |
--json / --machine | Structured output: { updated: <n>, removed: <n> }. | libra --json update-index --add a.txt |
Exit codes
| Code | Meaning |
|---|---|
0 | The index was updated and saved. |
128 | Not inside a repository, a usage error (bad --cacheinfo, untracked path without --add), or a missing working-tree file. |
Examples
# Build an index entry from an object id, then write the tree
OID=$(libra hash-object -w data.bin)
libra update-index --cacheinfo 100644,"$OID",assets/data.bin
libra write-tree
# Stage and unstage working-tree files
libra update-index --add src/new.rs
libra update-index --remove src/old.rsComparison with Git
| Task | Libra | Git |
|---|---|---|
| Stage a file | libra update-index --add f | git update-index --add f |
| Remove a path | libra update-index --remove f | git update-index --remove f |
| Register by id | libra update-index --cacheinfo m,oid,p | git update-index --cacheinfo m,oid,p |
Deferred (not exposed): bare-path stat refresh, --force-remove, --chmod,
--assume-unchanged, --skip-worktree, --index-info, and other Git flags.