1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Write patterns to "git grep" on stdin instead of passing them with "-e"

Summary:
Fixes T12807. Some shells may apparently mangle/strip UTF8 characters? Just dodge this whole problem by sending the pattern over stdin rather than actually figuring out the particulars.

Related tasks, like T7339 and T5554, discuss finding broader fixes for this class of issue, and this definitely isn't exactly a fully legitimate fix, but in many cases (as here) we can reasonably just avoid the problem rather than actually fixing it, at least for a long time.

Test Plan: Searched for emoji and non-emoji locally, but this worked fine (on OSX) for me before the patch too.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12807

Differential Revision: https://secure.phabricator.com/D18105
This commit is contained in:
epriestley 2017-06-08 05:53:39 -07:00
parent e26cd3ffe0
commit d5163d0143

View file

@ -57,11 +57,14 @@ final class DiffusionSearchQueryConduitAPIMethod
$results = array();
$future = $repository->getLocalCommandFuture(
// NOTE: --perl-regexp is available only with libpcre compiled in.
'grep --extended-regexp --null -n --no-color -e %s %s -- %s',
$grep,
'grep --extended-regexp --null -n --no-color -f - %s -- %s',
$drequest->getStableCommit(),
$path);
// NOTE: We're writing the pattern on stdin to avoid issues with UTF8
// being mangled by the shell. See T12807.
$future->write($grep);
$binary_pattern = '/Binary file [^:]*:(.+) matches/';
$lines = new LinesOfALargeExecFuture($future);