Class: Git::ExecutionContext::Global Private

Inherits:
Git::ExecutionContext show all
Defined in:
lib/git/execution_context/global.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.

Execution context for global git commands (no repository required)

Used for commands that do not require an existing repository — such as git init, git clone, and git version. Unlike Repository, this class leaves GIT_DIR, GIT_WORK_TREE, and GIT_INDEX_FILE as nil (which unsets them), so that the parent environment cannot leak an unintended repository context. GIT_SSH is still supported to allow SSH-based remote operations (e.g. git clone git@github.com:...).

Examples:

Create a context using the default git binary

context = Git::ExecutionContext::Global.new

Create a context targeting a specific binary

context = Git::ExecutionContext::Global.new(binary_path: '/usr/local/bin/git2')

Constant Summary

Constants inherited from Git::ExecutionContext

COMMAND_CAPTURING_ARG_DEFAULTS, COMMAND_STREAMING_ARG_DEFAULTS, STATIC_GLOBAL_OPTS

Instance Method Summary collapse

Methods inherited from Git::ExecutionContext

#binary_path, #command_capturing, #command_streaming, #git_dir, #git_index_file, #git_ssh, #git_version, #git_work_dir

Constructor Details

#initialize(binary_path: :use_global_config, git_ssh: :use_global_config, logger: nil) ⇒ Global

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

Creates a new global execution context

Examples:

Create with default settings

Git::ExecutionContext::Global.new

Create with an explicit binary path

Git::ExecutionContext::Global.new(binary_path: '/usr/local/bin/git2')

Parameters:

  • binary_path (String, :use_global_config) (defaults to: :use_global_config)

    path to the git binary

    Give :use_global_config (the default) to use Git::Base.config.binary_path.

    Passing nil raises ArgumentError — there is no "unset the binary" semantic.

  • git_ssh (String, nil, :use_global_config) (defaults to: :use_global_config)

    the SSH wrapper path

    Give nil to unset GIT_SSH, or :use_global_config (default) to use Git::Base.config.git_ssh.

  • logger (Logger, nil) (defaults to: nil)

    the logger to use in the CommandLine layer

    Give nil to use a null logger (Logger.new(nil)).

Raises:

  • (ArgumentError)

    if binary_path is nil



51
52
53
# File 'lib/git/execution_context/global.rb', line 51

def initialize(binary_path: :use_global_config, git_ssh: :use_global_config, logger: nil)
  super
end