private function buildBinaryChange(ArcanistDiffChange $change, $old_binary)
 {
     $eol = $this->getEOL('git');
     // In Git, when we write out a binary file move or copy, we need the
     // original binary for the source and the current binary for the
     // destination.
     if ($old_binary) {
         if ($old_binary->getOriginalFileData() !== null) {
             $old_data = $old_binary->getOriginalFileData();
             $old_phid = null;
         } else {
             $old_data = null;
             $old_phid = $old_binary->getMetadata('old:binary-phid');
         }
     } else {
         $old_data = $change->getOriginalFileData();
         $old_phid = $change->getMetadata('old:binary-phid');
     }
     if ($old_data === null && $old_phid) {
         $name = basename($change->getOldPath());
         $old_data = $this->getBlob($old_phid, $name);
     }
     $old_length = strlen($old_data);
     if ($old_data === null) {
         $old_data = '';
         $old_sha1 = str_repeat('0', 40);
     } else {
         $old_sha1 = sha1("blob {$old_length}{$old_data}");
     }
     $new_phid = $change->getMetadata('new:binary-phid');
     $new_data = null;
     if ($change->getCurrentFileData() !== null) {
         $new_data = $change->getCurrentFileData();
     } else {
         if ($new_phid) {
             $name = basename($change->getCurrentPath());
             $new_data = $this->getBlob($new_phid, $name);
         }
     }
     $new_length = strlen($new_data);
     if ($new_data === null) {
         $new_data = '';
         $new_sha1 = str_repeat('0', 40);
     } else {
         $new_sha1 = sha1("blob {$new_length}{$new_data}");
     }
     $content = array();
     $content[] = "index {$old_sha1}..{$new_sha1}" . $eol;
     $content[] = "GIT binary patch" . $eol;
     $content[] = "literal {$new_length}" . $eol;
     $content[] = $this->emitBinaryDiffBody($new_data) . $eol;
     $content[] = "literal {$old_length}" . $eol;
     $content[] = $this->emitBinaryDiffBody($old_data) . $eol;
     return implode('', $content);
 }