]> granicus.if.org Git - git/commit
fsmonitor: read entirety of watchman output
authorAlex Vandiver <alexmv@dropbox.com>
Wed, 4 Oct 2017 06:27:46 +0000 (23:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Oct 2017 09:58:53 +0000 (18:58 +0900)
commit2a387b17c5bc5e0872bed352a41a2b312ea86f9b
tree28e39bf1dc1bbff4003023509b0222b86b4c6f2c
parentdcdb71f1599734ae46870d3eca11e2093bbd7520
fsmonitor: read entirety of watchman output

In Perl, setting $/ sets the string that is used as the "record
separator," which sets the boundary that the `<>` construct reads to.
Setting `local $/ = 0666;` evaluates the octal, getting 438, and
stringifies it.  Thus, the later read from `<CHLD_OUT>` stops as soon
as it encounters the string "438" in the watchman output, yielding
invalid JSON; repositories containing filenames with SHA1 hashes are
able to trip this easily.

Set `$/` to undefined, thus slurping all output from watchman.  Also
close STDIN which is provided to watchman, to better guarantee that we
cannot deadlock with watchman while both attempting to read.

Signed-off-by: Alex Vandiver <alexmv@dropbox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7519/fsmonitor-watchman
templates/hooks--fsmonitor-watchman.sample