libra rerere

Command reference for `libra rerere`

REuse REcorded REsolution. Records how you resolved a merge conflict and replays that resolution automatically when the identical conflict reappears.

Synopsis

libra rerere [status | diff | forget <path>... | clear | gc]

Description

With no subcommand, rerere scans the tracked files for conflict markers and:

  • records a canonical preimage for each new conflict, tracking it in this worktree's local-gitdir MERGE_RR file;
  • if a recorded postimage (resolution) already matches a conflict, replays it with a three-way merge and writes the resolved content only when that merge is clean;
  • once a tracked conflict has been resolved by hand, records its postimage so the next identical conflict resolves itself.

A conflict is matched by the SHA-256 of its complete normalized conflict hunks: rerere drops a diff3 base section, sorts the two sides of each hunk lexicographically, and hashes only those sides. Thus swapped ours/theirs labels and unrelated surrounding edits still identify the same recorded resolution. Files without a complete conflict marker retain the historical whole-file hash fallback. Old whole-file-keyed cache entries coexist without migration; they simply miss and are learned again under the normalized key.

Subcommand Description
(none) Record preimages / replay resolutions / record postimages.
status List the paths whose conflicts are currently tracked.
diff Show what changed in each tracked file since its preimage was recorded.
forget <path>... Drop the recorded resolution for the given paths.
clear Stop tracking the current conflicts (recorded resolutions are kept).
gc Prune recorded resolutions older than the thresholds (60 days resolved / 15 days unresolved).

Exit codes

Code Meaning
0 Success.
128 Not inside a repository, forget of a path with no recording, or an I/O error.

Examples

# After a merge leaves conflicts, record them
libra rerere

# Resolve the files by hand, then let rerere learn the resolution
libra rerere

# The next time the same conflict appears, rerere resolves it for you
libra rerere status

Comparison with Git

Task Libra Git
Record / replay libra rerere git rerere
Inspect libra rerere status / diff git rerere status / diff
Drop / reset libra rerere forget <p> / clear / gc git rerere forget <p> / clear / gc

Automatic integration

When rerere.enabled is true, merge, rebase, and cherry-pick run rerere for you — there is no need to invoke libra rerere by hand:

  • when a conflict is written, the preimage is recorded and, if the normalized conflict was resolved before, the resolution is replayed into the working tree only after a clean three-way application;
  • when the conflict is resolved and the operation is committed / --continued, the postimage (your resolution) is recorded.

Enable it with:

libra config rerere.enabled true

With rerere.enabled unset (the default) these hooks are complete no-ops, so those commands behave exactly as before.

Staging of a replayed file follows rerere.autoUpdate (libra config rerere.autoUpdate true). merge, rebase, and cherry-pick each support --rerere-autoupdate / --no-rerere-autoupdate for a single invocation; the last flag wins and the choice persists through --continue.

The reusable cache lives under .libra/rerere/<id>/{preimage,postimage} and is repository-shared. A non-clean replay never overwrites the working file.