Page MenuHomePhabricator

D21484.id51137.diff
No OneTemporary

D21484.id51137.diff

diff --git a/src/applications/diffusion/controller/DiffusionServeController.php b/src/applications/diffusion/controller/DiffusionServeController.php
--- a/src/applications/diffusion/controller/DiffusionServeController.php
+++ b/src/applications/diffusion/controller/DiffusionServeController.php
@@ -922,18 +922,21 @@
// This is a pretty funky fix: it would be nice to more precisely detect
// that a request is a `--depth N` clone request, but we don't have any code
// to decode protocol frames yet. Instead, look for reasonable evidence
- // in the error and output that we're looking at a `--depth` clone.
+ // in the output that we're looking at a `--depth` clone.
- // For evidence this isn't completely crazy, see:
- // https://github.com/schacon/grack/pull/7
+ // A valid x-git-upload-pack-result response during packfile negotiation
+ // should end with a flush packet ("0000"). As long as that packet
+ // terminates the response body in the response, we'll assume the response
+ // is correct and complete.
+
+ // See https://git-scm.com/docs/pack-protocol#_packfile_negotiation
$stdout_regexp = '(^Content-Type: application/x-git-upload-pack-result)m';
- $stderr_regexp = '(The remote end hung up unexpectedly)';
$has_pack = preg_match($stdout_regexp, $stdout);
- $is_hangup = preg_match($stderr_regexp, $stderr);
+ $has_flush_packet = substr($stdout, -5) == "\n0000";
- return $has_pack && $is_hangup;
+ return $has_pack && $has_flush_packet;
}
private function getCommonEnvironment(PhabricatorUser $viewer) {

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 21, 1:54 PM (1 d, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7525775
Default Alt Text
D21484.id51137.diff (1 KB)

Event Timeline