Implements the Git.Command behaviour for git config.
Named GitConfig to avoid confusion with Git.Config which holds
wrapper configuration. Supports getting, setting, unsetting, and listing
git configuration values at local, global, or system scope.
Summary
Types
@type t() :: %Git.Commands.GitConfig{ add: boolean(), default: String.t() | nil, get: String.t() | nil, get_regexp: String.t() | nil, global: boolean(), list: boolean(), local: boolean(), name_only: boolean(), null_terminated: boolean(), set_key: String.t() | nil, set_value: String.t() | nil, system: boolean(), type: String.t() | nil, unset: String.t() | nil }
Functions
Returns the argument list for git config.
- If
:getis set, buildsgit config [--global|--local|--system] [--type] [--default] <key>. - If
:set_keyis set, buildsgit config [--global|--local|--system] [--add] [--type] <key> <value>. - If
:unsetis set, buildsgit config [--global|--local|--system] --unset <key>. - If
:get_regexpis set, buildsgit config [--global|--local|--system] --get-regexp <pattern>. - If
:listis true, buildsgit config [--global|--local|--system] --list.
Examples
iex> Git.Commands.GitConfig.args(%Git.Commands.GitConfig{get: "user.name"})
["config", "user.name"]
iex> Git.Commands.GitConfig.args(%Git.Commands.GitConfig{set_key: "user.name", set_value: "Test"})
["config", "user.name", "Test"]
iex> Git.Commands.GitConfig.args(%Git.Commands.GitConfig{list: true, local: true})
["config", "--local", "--list"]
iex> Git.Commands.GitConfig.args(%Git.Commands.GitConfig{unset: "user.name"})
["config", "--unset", "user.name"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, String.t()} | {:ok, [{String.t(), String.t()}]} | {:ok, :done} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git config.
For get operations (exit 0), returns {:ok, trimmed_value}.
For list operations (exit 0), returns {:ok, [{key, value}]}.
For set/unset operations (exit 0), returns {:ok, :done}.
On failure, returns {:error, {stdout, exit_code}}.