Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15486458
D18920.id45391.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D18920.id45391.diff
View Options
diff --git a/src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php b/src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php
--- a/src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php
@@ -76,6 +76,20 @@
PhabricatorRepository $repository,
PhabricatorRepositoryURI $mirror_uri) {
+ // See T5965. Test if we have any refs to mirror. If we have nothing, git
+ // will exit with an error ("No refs in common and none specified; ...")
+ // when we run "git push --mirror".
+
+ // If we don't have any refs, we just bail out. (This is arguably sort of
+ // the wrong behavior: to mirror an empty repository faithfully we should
+ // delete everything in the remote.)
+
+ list($stdout) = $repository->execxLocalCommand(
+ 'for-each-ref --count 1 --');
+ if (!strlen($stdout)) {
+ return;
+ }
+
$argv = array(
'push --verbose --mirror -- %P',
$mirror_uri->getURIEnvelope(),
diff --git a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
--- a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
@@ -399,6 +399,11 @@
'ls-remote %P',
$remote_envelope);
+ // Empty repositories don't have any refs.
+ if (!strlen(rtrim($stdout))) {
+ return array();
+ }
+
$map = array();
$lines = phutil_split_lines($stdout, false);
foreach ($lines as $line) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 11, 7:15 AM (6 d, 16 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7332156
Default Alt Text
D18920.id45391.diff (1 KB)
Attached To
Mode
D18920: Don't error when trying to mirror or observe an empty repository
Attached
Detach File
Event Timeline
Log In to Comment