Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/diffusion/ssh/DiffusionSSHGitReceivePackWorkflow.php b/src/applications/diffusion/ssh/DiffusionSSHGitReceivePackWorkflow.php
index 5ee501731e..fb5607792c 100644
--- a/src/applications/diffusion/ssh/DiffusionSSHGitReceivePackWorkflow.php
+++ b/src/applications/diffusion/ssh/DiffusionSSHGitReceivePackWorkflow.php
@@ -1,43 +1,44 @@
<?php
final class DiffusionSSHGitReceivePackWorkflow
extends DiffusionSSHGitWorkflow {
public function didConstruct() {
$this->setName('git-receive-pack');
$this->setArguments(
array(
array(
'name' => 'dir',
'wildcard' => true,
),
));
}
protected function executeRepositoryOperations() {
$args = $this->getArgs();
$path = head($args->getArg('dir'));
$repository = $this->loadRepository($path);
// This is a write, and must have write access.
$this->requireWriteAccess();
$future = new ExecFuture(
'git-receive-pack %s',
$repository->getLocalPath());
$err = $this->newPassthruCommand()
->setIOChannel($this->getIOChannel())
->setCommandChannelFromExecFuture($future)
->execute();
if (!$err) {
$repository->writeStatusMessage(
PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE,
PhabricatorRepositoryStatusMessage::CODE_OKAY);
+ $this->waitForGitClient();
}
return $err;
}
}
diff --git a/src/applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php b/src/applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php
index 38d16dd741..35026b4bf8 100644
--- a/src/applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php
+++ b/src/applications/diffusion/ssh/DiffusionSSHGitUploadPackWorkflow.php
@@ -1,30 +1,36 @@
<?php
final class DiffusionSSHGitUploadPackWorkflow
extends DiffusionSSHGitWorkflow {
public function didConstruct() {
$this->setName('git-upload-pack');
$this->setArguments(
array(
array(
'name' => 'dir',
'wildcard' => true,
),
));
}
protected function executeRepositoryOperations() {
$args = $this->getArgs();
$path = head($args->getArg('dir'));
$repository = $this->loadRepository($path);
$future = new ExecFuture('git-upload-pack %s', $repository->getLocalPath());
- return $this->newPassthruCommand()
+ $err = $this->newPassthruCommand()
->setIOChannel($this->getIOChannel())
->setCommandChannelFromExecFuture($future)
->execute();
+
+ if (!$err) {
+ $this->waitForGitClient();
+ }
+
+ return $err;
}
}
diff --git a/src/applications/diffusion/ssh/DiffusionSSHGitWorkflow.php b/src/applications/diffusion/ssh/DiffusionSSHGitWorkflow.php
index ceaf7c146e..d70551607f 100644
--- a/src/applications/diffusion/ssh/DiffusionSSHGitWorkflow.php
+++ b/src/applications/diffusion/ssh/DiffusionSSHGitWorkflow.php
@@ -1,10 +1,23 @@
<?php
abstract class DiffusionSSHGitWorkflow extends DiffusionSSHWorkflow {
protected function writeError($message) {
// Git assumes we'll add our own newlines.
return parent::writeError($message."\n");
}
+ protected function waitForGitClient() {
+ $io_channel = $this->getIOChannel();
+
+ // If we don't wait for the client to close the connection, `git` will
+ // consider it an early abort and fail. Sit around until Git is comfortable
+ // that it really received all the data.
+ while ($io_channel->isOpenForReading()) {
+ $io_channel->update();
+ $this->getErrorChannel()->flush();
+ PhutilChannel::waitForAny(array($io_channel));
+ }
+ }
+
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Oct 31, 3:16 AM (1 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
311966
Default Alt Text
(3 KB)

Event Timeline