>     I have appended a patch which should fix the problem. Could you,
>     please, (let) test?
>
> Great, I'll make them test & report (or test myself if needed).

FTR, this morning I've made a test with a cloned Linux kernel git repo
(66473 files). I've accessed the directory via "/ssh::".
(shell-command-to-string "git ls-files -zco --exclude-standard")
returned in a few seconds, with a line of 2479486 bytes.

Is that with or without the patch? Could you reproduce the problem without the patch?

 
I've committed the patch meanwhile. Tramp 2.4.3, scheduled for end of
the year, will contain it.

In case there's a problem, you still have some days to report :-)

Great, thanks!

Kind regards,
Philippe