Class: Git::Commands::WriteTree Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/write_tree.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-write-tree/2.53.0

Implements the git write-tree command

Creates a tree object using the current index and prints the SHA-1 name of the new tree object to standard output. The index must be in a fully merged state.

Examples:

Write the current index as a tree object

write_tree = Git::Commands::WriteTree.new(execution_context)
result = write_tree.call
sha = result.stdout   # => "abc123..."

Write only a subdirectory as a tree object

write_tree = Git::Commands::WriteTree.new(execution_context)
result = write_tree.call(prefix: 'lib/')

Allow missing objects in the object database

write_tree = Git::Commands::WriteTree.new(execution_context)
result = write_tree.call(missing_ok: 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(**options) ⇒ Git::CommandLineResult

Execute the git write-tree command

Parameters:

  • options (Hash)

    command options

Options Hash (**options):

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

    disable the check that all objects referenced by the directory exist in the object database

  • :prefix (String) — default: nil

    write a tree object that represents a subdirectory

    The prefix path should end with / (e.g., 'lib/').

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/write_tree.rb', line 41