Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14237621
D20786.id49562.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
D20786.id49562.diff
View Options
diff --git a/src/land/ArcanistGitLandEngine.php b/src/land/ArcanistGitLandEngine.php
--- a/src/land/ArcanistGitLandEngine.php
+++ b/src/land/ArcanistGitLandEngine.php
@@ -473,8 +473,9 @@
private function destroyLocalBranch() {
$api = $this->getRepositoryAPI();
+ $source_ref = $this->getSourceRef();
- if ($this->getSourceRef() == $this->getTargetOnto()) {
+ if ($source_ref == $this->getTargetOnto()) {
// If we landed a branch into a branch with the same name, so don't
// destroy it. This prevents us from cleaning up "master" if you're
// landing master into itself.
@@ -483,20 +484,32 @@
// TODO: Maybe this should also recover the proper upstream?
+ // See T10321. If we were not landing a branch, don't try to clean it up.
+ // This happens most often when landing from a detached HEAD.
+ $is_branch = $this->isBranch($source_ref);
+ if (!$is_branch) {
+ echo tsprintf(
+ "%s\n",
+ pht(
+ '(Source "%s" is not a branch, leaving working copy as-is.)',
+ $source_ref));
+ return;
+ }
+
$recovery_command = csprintf(
'git checkout -b %R %R',
- $this->getSourceRef(),
+ $source_ref,
$this->sourceCommit);
echo tsprintf(
"%s\n",
- pht('Cleaning up branch "%s"...', $this->getSourceRef()));
+ pht('Cleaning up branch "%s"...', $source_ref));
echo tsprintf(
"%s\n",
pht('(Use `%s` if you want it back.)', $recovery_command));
- $api->execxLocal('branch -D -- %s', $this->getSourceRef());
+ $api->execxLocal('branch -D -- %s', $source_ref);
}
/**
@@ -592,4 +605,14 @@
'same state as before.'));
}
+ private function isBranch($ref) {
+ $api = $this->getRepositoryAPI();
+
+ list($err) = $api->execManualLocal(
+ 'show-ref --verify --quiet -- %R',
+ 'refs/heads/'.$ref);
+
+ return !$err;
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 13, 1:19 PM (21 h, 44 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6876099
Default Alt Text
D20786.id49562.diff (1 KB)
Attached To
Mode
D20786: When running "arc land" from a detached HEAD, don't try to delete the source ref
Attached
Detach File
Event Timeline
Log In to Comment