Subject: Re: [PATCH 4/4] meson: add rule to run 'git clang-format'

From: Junio C Hamano <[email-masked]>
Date: Mon, 30 Jun 2025 08:24:54 -0700

Karthik Nayak <[email-masked]> writes:

>>>>> +clang_format = find_program('clang-format', required: false)
>>>>
>>>> Should we be checking for `git-clang-format` instead?
>>>
>>> Yeah. While `git-clang-format` is packaged with `clang-format`, it does
>>> make more sense to check for the former.
>>
>> Just for my education, what does find_program() look for?  Installed
>> packages, or a program on your $PATH?  I am guessing that the answer
>> is the latter, in which case it is not like "it makes more sense to
>> check for git-clang-format"---rather it is "it would not work at all
>> if we looked for clang-format", no?
>>
>> Thanks.
>
> Good question. To quote from the documentation [1]:
>
>   find_program()
>
>   program_name here is a string that can be an executable or script to
>   be searched for in PATH or other places inside the project.
>
> So, 'git-clang-format' would work. I've also verified the same on my
> end.

I think that much everybody would know by what other uses of
find_program() are looking for by checking "git grep find_program"
output.

I was confused by your "it does make *MORE* sense to check for the
former" (emphasis mine), as if you were saying that both would work
but using 'git-clang-format' would be a more kosher way to express
what we want.  Given that it would not work at all if you used
'clang-format' instead, that statement was misleading.

So the response I was expecting in the message I am responding to
was more like "'clang-format' would *not* work at all, and we must
check 'git-clang-format' instead".

Thanks.