Re: [PATCH 4/4] meson: add rule to run 'git clang-format'
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 30, 2025, 15:24 UTC
- Message-ID
- <xmqq4ivx5k1l.fsf@gitster.g>
- In-Reply-To
- <CAOLa=ZQD71Z4GSRNCuV=YL1zwGOXa-sGzpU9=8yfVcg6vJA6SQ@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 24 quoted lines
>>>>> +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.