filter-process: Fix protocol for empty files

This caused git to complain that filter-process failed and kill it with
signal 15. Because it wrote an extra flushPkt for an empty file, which
git did not expect, and so git saw an unexpected response to the next
request.

Luckily, filter-process is only used by default in v9 and up, and v8 is
still the default. Also, git had to be updating an empty file, followed
by another file, which is a fairly unlikely situation. And git restarts
filter-process after this happens and uses it to filter the rest of the
files. So this isn't a crippling bug.

Sponsored-by: Luke Shumaker on Patreon
This commit is contained in:
Joey Hess 2022-07-13 17:13:54 -04:00
parent 1b680d330b
commit fbc3c223a6
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 167 additions and 1 deletions

View file

@ -162,7 +162,9 @@ respondFilterRequest b = do
send b' =
let (pktline, rest) = encodePktLine b'
in do
writePktLine stdout pktline
if isFlushPkt pktline
then return ()
else writePktLine stdout pktline
case rest of
Just b'' -> send b''
Nothing -> writePktLine stdout flushPkt