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 merge-base

Command reference for `libra merge-base`

Find the best common ancestor(s) of two commits — a focused subset of git merge-base. Backed by the single lowest-common-ancestor (LCA) implementation in internal/merge_base.rs, which diff A...B also uses.

Synopsis

libra merge-base <commit> <commit>
libra merge-base --all <commit> <commit>
libra merge-base --is-ancestor <commit> <commit>

Description

Given two commits, merge-base prints their best common ancestor — a true LCA: a common ancestor that is not itself a strict ancestor of another common ancestor. For a normal "Y" history that is the point where the branches diverged. In criss-cross histories there can be several LCAs; --all prints all of them, while the default prints one (deterministically chosen).

With --is-ancestor, nothing is printed; the exit code answers whether the first commit is an ancestor of the second.

Each <commit> may be a branch, tag, HEAD, or an object id.

Options

OptionDescriptionExample
--allPrint every lowest common ancestor, not just one.libra merge-base --all main feature
--is-ancestorTest ancestry (exit 0/1) instead of printing a base.libra merge-base --is-ancestor v1 main
--json / --machineStructured output: { bases: [...] } or { is_ancestor }.libra --json merge-base main feature

Exit codes

CodeMeaning
0A merge base was printed, or (--is-ancestor) the first commit is an ancestor of the second.
1No common ancestor exists, or (--is-ancestor) the first commit is not an ancestor of the second. No output.
128A commit could not be resolved, or the wrong number of arguments was given.

Examples

# Where did main and feature diverge?
libra merge-base main feature

# Is the release tag still on the main line?
libra merge-base --is-ancestor v1.0 main && echo "yes, fast-forwardable"

# Diff a feature against where it branched from main
libra diff main...feature

Comparison with Git

TaskLibraGit
Best common ancestorlibra merge-base a bgit merge-base a b
All merge baseslibra merge-base --all a bgit merge-base --all a b
Ancestry testlibra merge-base --is-ancestor a bgit merge-base --is-ancestor a b

Deferred (not yet exposed): more than two commits and --octopus / --independent / --fork-point. (The log / rebase internals still use their own first-found walk; migrating them onto this shared LCA is a tracked follow-up.)

libra media

Command reference for `libra media`

libra merge-file

Command reference for `libra merge-file`

On this page

SynopsisDescriptionOptionsExit codesExamplesComparison with Git