Class: Git::Commands::MergeBase Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/merge_base.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

arguments block audited against https://git-scm.com/docs/git-merge-base/2.53.0

Implements the git merge-base command to find common ancestors

Finds as good common ancestors as possible for use in a three-way merge. Given two or more commits, it outputs a common ancestor reachable from all of them through the parent relationship.

Examples:

Find merge bases of two branches

merge_base = Git::Commands::MergeBase.new(execution_context)
merge_base.call('main', 'feature')
merge_base.call('main', 'feature', all: true)
merge_base.call('main', 'b1', 'b2', octopus: true)
merge_base.call('main', 'feature', fork_point: true)

See Also:

Instance Method Summary collapse

Methods inherited from Base

allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation

Constructor Details

This class inherits a constructor from Git::Commands::Base

Instance Method Details

#call(*commit, **options) ⇒ Git::CommandLineResult

Execute the git merge-base command

Parameters:

  • commit (Array<String>)

    two or more commit SHAs, branch names, or refs to find common ancestor(s) of

  • options (Hash)

    command options

Options Hash (**options):

  • :octopus (Boolean, nil) — default: nil

    compute best common ancestor for an n-way merge (intersection of all merge bases)

  • :independent (Boolean, nil) — default: nil

    list commits not reachable from any other; useful for finding minimal merge points

  • :is_ancestor (Boolean, nil) — default: nil

    check if the first commit is an ancestor of the second; exits 0 if true, 1 if not

  • :fork_point (Boolean, nil) — default: nil

    find the fork point where a branch diverged from another, consulting the reflog

  • :all (Boolean, nil) — default: nil

    output all merge bases instead of just one when multiple equally good bases exist

    Alias: :a

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits outside the allowed range (exit code > 1)



# File 'lib/git/commands/merge_base.rb', line 49