Class: Git::Commands::ConfigOptionSyntax::Get Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/config_option_syntax/get.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-config/2.53.0

Retrieve a single config value by exact key name

Wraps git config --get to return the value of the last-matching config entry for the given key name.

Examples:

Get a local config value

cmd = Git::Commands::ConfigOptionSyntax::Get.new(lib)
cmd.call('user.name')

Get a global config value

cmd = Git::Commands::ConfigOptionSyntax::Get.new(lib)
cmd.call('user.name', global: true)

Get a value with a type constraint

cmd = Git::Commands::ConfigOptionSyntax::Get.new(lib)
cmd.call('core.bare', type: 'bool')

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(name, value_regex = nil, **options) ⇒ Git::CommandLineResult

Execute the git config --get command

Parameters:

  • name (String)

    the config key name to look up

  • value_regex (String, nil) (defaults to: nil)

    (nil) optional regex to filter the value

  • options (Hash)

    command options

Options Hash (**options):

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

    read from global config (~/.gitconfig)

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

    read from system config

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

    read from repository config (.git/config)

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

    read from worktree config

  • :file (String) — default: nil

    read from the specified file

    Alias: :f

  • :blob (String) — default: nil

    read from the specified blob

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

    respect include directives in config files (--includes)

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

    do not respect include directives in config files (--no-includes)

  • :type (String) — default: nil

    ensure the value conforms to the given type

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

    show the origin of the config value

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

    show the scope of the config value

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

    terminate values with NUL byte instead of newline

    Alias: :z

  • :default (String) — default: nil

    default value when the key is not found

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits outside the allowed status range (0..1)



# File 'lib/git/commands/config_option_syntax/get.rb', line 66