Merge branch 'ps/builtin-config-cleanup'

Code clean-up to reduce inter-function communication inside
builtin/config.c done via the use of global variables.

* ps/builtin-config-cleanup: (21 commits)
  builtin/config: pass data between callbacks via local variables
  builtin/config: convert flags to a local variable
  builtin/config: track "fixed value" option via flags only
  builtin/config: convert `key` to a local variable
  builtin/config: convert `key_regexp` to a local variable
  builtin/config: convert `regexp` to a local variable
  builtin/config: convert `value_pattern` to a local variable
  builtin/config: convert `do_not_match` to a local variable
  builtin/config: move `respect_includes_opt` into location options
  builtin/config: move default value into display options
  builtin/config: move type options into display options
  builtin/config: move display options into local variables
  builtin/config: move location options into local variables
  builtin/config: refactor functions to have common exit paths
  config: make the config source const
  builtin/config: check for writeability after source is set up
  builtin/config: move actions into `cmd_config_actions()`
  builtin/config: move legacy options into `cmd_config()`
  builtin/config: move subcommand options into `cmd_config()`
  builtin/config: move legacy mode into its own function
  ...
This commit is contained in:
Junio C Hamano
2024-05-28 11:17:07 -07:00
4 changed files with 549 additions and 430 deletions

File diff suppressed because it is too large Load Diff

View File

@ -125,7 +125,7 @@ struct config_include_data {
config_fn_t fn; config_fn_t fn;
void *data; void *data;
const struct config_options *opts; const struct config_options *opts;
struct git_config_source *config_source; const struct git_config_source *config_source;
struct repository *repo; struct repository *repo;
/* /*
@ -2117,7 +2117,7 @@ static int do_git_config_sequence(const struct config_options *opts,
} }
int config_with_options(config_fn_t fn, void *data, int config_with_options(config_fn_t fn, void *data,
struct git_config_source *config_source, const struct git_config_source *config_source,
struct repository *repo, struct repository *repo,
const struct config_options *opts) const struct config_options *opts)
{ {

View File

@ -232,7 +232,7 @@ void git_config(config_fn_t fn, void *);
* sets `opts.respect_includes` to `1` by default. * sets `opts.respect_includes` to `1` by default.
*/ */
int config_with_options(config_fn_t fn, void *, int config_with_options(config_fn_t fn, void *,
struct git_config_source *config_source, const struct git_config_source *config_source,
struct repository *repo, struct repository *repo,
const struct config_options *opts); const struct config_options *opts);

View File

@ -596,7 +596,8 @@ test_expect_success 'get bool variable with empty value' '
test_expect_success 'no arguments, but no crash' ' test_expect_success 'no arguments, but no crash' '
test_must_fail git config >output 2>&1 && test_must_fail git config >output 2>&1 &&
test_grep usage output echo "error: no action specified" >expect &&
test_cmp expect output
' '
cat > .git/config << EOF cat > .git/config << EOF
@ -2834,6 +2835,12 @@ test_expect_success 'specifying multiple modes causes failure' '
test_cmp expect err test_cmp expect err
' '
test_expect_success 'writing to stdin is rejected' '
echo "fatal: writing to stdin is not supported" >expect &&
test_must_fail git config ${mode_set} --file - foo.bar baz 2>err &&
test_cmp expect err
'
done done
test_done test_done