In "config.c" we host both the business logic to read and write config files as well as the logic to parse specific Git-related variables. On the one hand this is mixing concerns, but even more importantly it means that we cannot easily remove the dependency on `the_repository` in our config parsing logic. Move the logic into "environment.c". This file is a grab bag of all kinds of global state already, so it is quite a good fit. Furthermore, it also hosts most of the global variables that we're parsing the config values into, making this an even better fit. Note that there is one hidden change: in `parse_fsync_components()` we use an `int` to iterate through `ARRAY_SIZE(fsync_component_names)`. But as -Wsign-compare warnings are enabled in this file this causes a compiler warning. The issue is fixed by using a `size_t` instead. This change allows us to drop the `USE_THE_REPOSITORY_VARIABLE` declaration. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
26 lines
553 B
C
26 lines
553 B
C
#define USE_THE_REPOSITORY_VARIABLE
|
|
|
|
#include "test-tool.h"
|
|
#include "advice.h"
|
|
#include "config.h"
|
|
#include "environment.h"
|
|
#include "setup.h"
|
|
|
|
int cmd__advise_if_enabled(int argc, const char **argv)
|
|
{
|
|
if (argc != 2)
|
|
die("usage: %s <advice>", argv[0]);
|
|
|
|
setup_git_directory();
|
|
repo_config(the_repository, git_default_config, NULL);
|
|
|
|
/*
|
|
* Any advice type can be used for testing, but NESTED_TAG was
|
|
* selected here and in t0018 where this command is being
|
|
* executed.
|
|
*/
|
|
advise_if_enabled(ADVICE_NESTED_TAG, "%s", argv[1]);
|
|
|
|
return 0;
|
|
}
|