Re: [RFC PATCH 1/2] config: make git_config_include() static
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 13, 2021, 17:00 UTC
- Message-ID
- <xmqqk0igj1vf.fsf@gitster.g>
- In-Reply-To
- <87sfx5ib3h.fsf@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 44 quoted lines
> On Tue, Oct 12 2021, Jonathan Tan wrote:
>
>> It is not used from outside the file in which it is declared.
>>
>> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
>> ---
>> config.c | 12 +++++++++++-
>> config.h | 37 ++++---------------------------------
>> 2 files changed, 15 insertions(+), 34 deletions(-)
>>
>> diff --git a/config.c b/config.c
>> index 2edf835262..365d57833b 100644
>> --- a/config.c
>> +++ b/config.c
>> @@ -120,6 +120,16 @@ static long config_buf_ftell(struct config_source *conf)
>> return conf->u.buf.pos;
>> }
>>
>> +struct config_include_data {
>> + int depth;
>> + config_fn_t fn;
>> + void *data;
>> + const struct config_options *opts;
>> +};
>> +#define CONFIG_INCLUDE_INIT { 0 }
>> +
>> +static int git_config_include(const char *var, const char *value, void *data);
>
> Can't we just move the function here?
>
>> #define MAX_INCLUDE_DEPTH 10
>> static const char include_depth_advice[] = N_(
>> "exceeded maximum include depth (%d) while including\n"
>> @@ -306,7 +316,7 @@ static int include_condition_is_true(const struct config_options *opts,
>> return 0;
>> }
>>
>> -int git_config_include(const char *var, const char *value, void *data)
>> +static int git_config_include(const char *var, const char *value, void *data)
>
> ...and avoid the forward declaration?
>
> I've seen that in a few places, making the diff smaller here doesn't
> seem worth it v.s. maintaining the definition in two places.Sounds good. If we are moving things around anyway, it is probably a good time to do that, too ;-)