Empty commit causes diffusion error output


#1

Observed Behavior:
A user had a complex rebase that was resulting in an empty commit (in the stack of changes), I was able to simply reproduce this using git commit --allow-empty and pushing

$ git push
Counting objects: 34, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (26/26), done.
Writing objects: 100% (34/34), 3.70 KiB | 0 bytes/s, done.
Total 34 (delta 29), reused 9 (delta 8)
remote: [2018-06-13 09:24:36] ERROR 8: Undefined offset: 0 at [/opt/phacility/phabricator/src/applications/diffusion/engine/DiffusionCommitHookEngine.php:1135]
remote: arcanist(head=stable, ref.master=5eda40337bb4, ref.stable=8b1be5b87f04), phabricator(head=stable, ref.master=df21391b8e7b, ref.stable=2d1bc72b1aff, custom=7), phutil(head=stable, ref.master=276f6d304b69, ref.stable=47c97f0c4842)
remote:   #0 DiffusionCommitHookEngine::rejectEnormousChanges(array) called at [<phabricator>/src/applications/diffusion/engine/DiffusionCommitHookEngine.php:159]
remote:   #1 DiffusionCommitHookEngine::execute() called at [<phabricator>/scripts/repository/commit_hook.php:196]
remote: [2018-06-13 09:24:36] ERROR 8: Undefined offset: 1 at [/opt/phacility/phabricator/src/applications/diffusion/engine/DiffusionCommitHookEngine.php:1135]
remote: arcanist(head=stable, ref.master=5eda40337bb4, ref.stable=8b1be5b87f04), phabricator(head=stable, ref.master=df21391b8e7b, ref.stable=2d1bc72b1aff, custom=7), phutil(head=stable, ref.master=276f6d304b69, ref.stable=47c97f0c4842)
remote:   #0 DiffusionCommitHookEngine::rejectEnormousChanges(array) called at [<phabricator>/src/applications/diffusion/engine/DiffusionCommitHookEngine.php:159]
remote:   #1 DiffusionCommitHookEngine::execute() called at [<phabricator>/scripts/repository/commit_hook.php:196]
To ssh://<our instance>/source/<repo>.git
   dcbcadc..d0b9ab0  mybranch -> mybranch

Expected Behavior:
The push didn’t outright reject but the error is obviously concerning/may have side effects?

Phabricator Version:

phabricator
    38557b96c27edb7de2ba1f4023b92c47df82635c (Tue, Jun 12) (branched from 59b95f9397809a70d4b09114ff84ec2b98e40495 on origin) 
arcanist
    8b1be5b87f046ce513f011fbf795ea892f72f215 (Fri, Jun 8) (branched from df7313bdf2a34d03667fe20c850a10ad3878e27d on origin) 
phutil
    47c97f0c48429a25f35ca9b515c7b9e15889d77f (Fri, Jun 8) (branched from 4206849bb05b60f536a1c78e33adee68dac67aa9 on origin) 
diff
    3.6 at /bin/diff 
git
    2.17.1 at /bin/git 
hg
    Not Available 
pygmentize
    2.2.0 at /bin/pygmentize 
svn
    1.10.0 at /bin/svn 

Reproduction Steps:
With a repo (enormous changes NOT enabled) I was able to reproduce with a git commit --allow-empty and git push

Obviously not the real resolution but as a test for my empty commits, I applied this patch to verify and it did get rid of the error

diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
index 857c939a2..29156e7b3 100644
--- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
+++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
@@ -1131,13 +1131,15 @@ final class DiffusionCommitHookEngine extends Phobject {
     foreach ($content_updates as $update) {
       $identifier = $update->getRefNew();
       try {
-        $info = $this->loadChangesetsForCommit($identifier);
+       $info = $this->loadChangesetsForCommit($identifier);
+       if (sizeof($info) > 0) {
         list($changesets, $size) = $info;
 
         if ($this->changesetsSize + $size <= $cache_limit) {
           $this->changesets[$identifier] = $changesets;
           $this->changesetsSize += $size;
-        }
+       }
+       }
       } catch (Exception $ex) {
         $this->changesets[$identifier] = $ex;