Page MenuHomePhabricator

D21484.diff
No OneTemporary

D21484.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,26 @@
// 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);
- return $has_pack && $is_hangup;
+ if (strlen($stdout) >= 4) {
+ $has_flush_packet = (substr($stdout, -4) === "0000");
+ } else {
+ $has_flush_packet = false;
+ }
+
+ return ($has_pack && $has_flush_packet);
}
private function getCommonEnvironment(PhabricatorUser $viewer) {

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 2:04 AM (3 h, 54 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6773227
Default Alt Text
D21484.diff (1 KB)

Event Timeline