mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Respond more gracefully when a git push deletes a nonexistent ref
Summary: Fixes T5534. If you `git push origin :refs/tags/doesnotexist` (for some non-existing tag), we get a change where both the old and new refs are empty. We incorrectly call this an "add", because the old ref is empty. Instead, call this a "delete", but skip the logic which would normally mark it dangerous. (Possibly we should just reject these outright, but Git allows them, so stick with that for now.) Test Plan: Pushed nonexistent refs: ``` $ git push origin :refs/tags/doesnotexist remote: warning: Allowing deletion of corrupt ref. To ssh://dweller@localhost/diffusion/POEMS/ - [deleted] doesnotexist $ ``` Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5534 Differential Revision: https://secure.phabricator.com/D9800
This commit is contained in:
parent
16648c28bc
commit
02c3200867
1 changed files with 6 additions and 1 deletions
|
@ -477,7 +477,12 @@ final class DiffusionCommitHookEngine extends Phobject {
|
||||||
$ref_flags = 0;
|
$ref_flags = 0;
|
||||||
$dangerous = null;
|
$dangerous = null;
|
||||||
|
|
||||||
if ($ref_old === self::EMPTY_HASH) {
|
if (($ref_old === self::EMPTY_HASH) && ($ref_new === self::EMPTY_HASH)) {
|
||||||
|
// This happens if you try to delete a tag or branch which does not
|
||||||
|
// exist by pushing directly to the ref. Git will warn about it but
|
||||||
|
// allow it. Just call it a delete, without flagging it as dangerous.
|
||||||
|
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE;
|
||||||
|
} else if ($ref_old === self::EMPTY_HASH) {
|
||||||
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_ADD;
|
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_ADD;
|
||||||
} else if ($ref_new === self::EMPTY_HASH) {
|
} else if ($ref_new === self::EMPTY_HASH) {
|
||||||
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE;
|
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE;
|
||||||
|
|
Loading…
Reference in a new issue