commit.ListFiles does not handle git sub-cmd status
Extracted from !4932 (merged)
When working on Add offset/pagination support to SearchFilesByN... (#4449 - closed), I noticed that when some RPCs don't capture the status of git sub-command after spawning them. It's a common theme that those RPCs return a list of objects (essentially files, or refs), etc. They reads stdout until EOF. When something goes wrong, the stdout pipe is closed. As a result, those RPCs return an empty array when they perform a wrong query or target a wrong ref. I'm uncertain whether this is intentionally a feature, or just unnoticed bugs. That said, it's not possible to differentiate between real empty results or unexpected git sub-cmd bugs.
commit.ListFiles RPC issues git ls-tree --full-tree --name-status -r -z main .
command. If the ref does not exist, the git command exits with 128 code, and the following message in stderr:
fatal: Not a valid object name main