@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+6 -1
+6 -1
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
··· 477 477 $ref_flags = 0; 478 478 $dangerous = null; 479 479 480 - if ($ref_old === self::EMPTY_HASH) { 480 + if (($ref_old === self::EMPTY_HASH) && ($ref_new === self::EMPTY_HASH)) { 481 + // This happens if you try to delete a tag or branch which does not 482 + // exist by pushing directly to the ref. Git will warn about it but 483 + // allow it. Just call it a delete, without flagging it as dangerous. 484 + $ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE; 485 + } else if ($ref_old === self::EMPTY_HASH) { 481 486 $ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_ADD; 482 487 } else if ($ref_new === self::EMPTY_HASH) { 483 488 $ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE;