git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] meson: Tolerate errors from git ls-files --deduplicate

From
Martin Storsjö <martin@martin.st>
Date
Aug 1, 2025, 10:24 UTC
Message-ID
<dff715f2-9d26-148-5046-6b7190b9414f@martin.st>
In-Reply-To
<aIyMuUZaARaTpmOh@pks.im>
On Fri, 1 Aug 2025, Patrick Steinhardt wrote:
Show 45 quoted lines
> On Fri, Aug 01, 2025 at 12:42:52PM +0300, Martin Storsjö wrote:
>> On Fri, 1 Aug 2025, Patrick Steinhardt wrote:
>>
>>> On Fri, Aug 01, 2025 at 10:56:22AM +0300, Martin Storsjö wrote:
>>>> index 9bc1826cb6..9b519e6eed 100644
>>>> --- a/meson.build
>>>> +++ b/meson.build
>>>> @@ -694,9 +694,12 @@ third_party_excludes = [
>>>>
>>>>  headers_to_check = []
>>>>  if git.found() and fs.exists(meson.project_source_root() / '.git')
>>>> -  foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_excludes, check: true).stdout().split()
>>>> -    headers_to_check += header
>>>> -  endforeach
>>>> +  ls_headers = run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_excludes, check: false)
>>>> +  if ls_headers.returncode() == 0
>>>> +    foreach header : ls_headers.stdout().split()
>>>> +      headers_to_check += header
>>>> +    endforeach
>>>> +  endif
>>>>  endif
>>>
>>> Yup, this looks reasonable to me. We could have an `else` branch that
>>> warns about the command failing, for example like this:
>>>
>>>    warning("could not find headers: " + ls_headers.stderr())
>>
>> This would work - however the output from ls_headers.stderr() is fairly long
>> (if you try running e.g. "git ls-files --foobar", you'll get a 37 line
>> listing of potential options); it's rather distracting for what's otherwise
>> a fairly minor build configuration issue.
>>
>> Using ls_headers.stderr().split('\n')[0] works and just gets us this:
>>
>>     ../meson.build:703: WARNING: could not find headers: error: unknown option `deduplicate'
>>
>> However I wonder if it's worth it, or if it just makes the meson file
>> potentially more brittle? (E.g. what if split() returns an array of 0
>> elements? Not sure if that's possible though...)
>
> True. Maybe we can just not include stderr at all but say:
>
>    could not list headers, disabling static analysis targets
>
> That's probably sufficient.
Thanks, that sounds reasonable!
// Martin
Previous: Patrick SteinhardtNext: Martin Storsjö
Message 8 of 13 in “meson: Check whether git is new enough to support ls-files --deduplicate”
  1. meson: Check whether git is new enough to support ls-files --deduplicateMartin Storsjö, Jul 31, 2025
  2. Patrick SteinhardtAug 1, 2025
  3. Martin StorsjöAug 1, 2025
  4. meson: Tolerate errors from git ls-files --deduplicateMartin Storsjö, Aug 1, 2025
  5. Patrick SteinhardtAug 1, 2025
  6. Martin StorsjöAug 1, 2025
  7. Patrick SteinhardtAug 1, 2025
  8. Martin StorsjöAug 1, 2025
  9. meson: Tolerate errors from git ls-files --deduplicateMartin Storsjö, Aug 1, 2025
  10. Patrick SteinhardtAug 1, 2025
  11. Junio C HamanoAug 1, 2025
  12. Martin StorsjöAug 1, 2025
  13. meson: Tolerate errors from git ls-files --deduplicateMartin Storsjö, Aug 1, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.