@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.

Fix a fatal in the document engine blame view with files that blame to the initial commit

Summary:
Ref T13126. When you view a file using the new document engine view and some lines were introduced in the initial commit to the repository, Git renders "^abc123" in the blame output.

We currently don't do anything about this, and later fail to look it up and fatal.

It's also unlikely-but-conceivably-possible to end up here if a commit has not imported yet or has been nuked with `bin/remove destroy`.

Let the whole thing run without fataling even if a `$commit` is missing. Future refinements could improve this behavior.

Test Plan: Viewed a file with lines introduced in the initial commit, got empty blame instead of a fatal.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13126

Differential Revision: https://secure.phabricator.com/D19391

+35 -15
+35 -15
src/applications/diffusion/controller/DiffusionBlameController.php
··· 80 80 81 81 $handles = $viewer->loadHandles($handle_phids); 82 82 83 - 84 83 $map = array(); 85 84 $epochs = array(); 86 85 foreach ($identifiers as $identifier) { ··· 106 105 ), 107 106 $skip_icon); 108 107 109 - $commit = $commits[$identifier]; 108 + // We may not have a commit object for a given identifier if the commit 109 + // has not imported yet. 110 + 111 + // At time of writing, this can also happen if a line was part of the 112 + // initial import: blame produces a "^abc123" identifier in Git, which 113 + // doesn't correspond to a real commit. 114 + 115 + $commit = idx($commits, $identifier); 116 + 117 + $author_phid = null; 118 + 119 + if ($commit) { 120 + $author_phid = $commit->getAuthorPHID(); 121 + } 110 122 111 - $author_phid = $commit->getAuthorPHID(); 112 123 if (!$author_phid && $revision) { 113 124 $author_phid = $revision->getAuthorPHID(); 114 125 } ··· 141 152 'meta' => $author_meta, 142 153 )); 143 154 144 - $commit_link = javelin_tag( 145 - 'a', 146 - array( 147 - 'href' => $commit->getURI(), 148 - 'sigil' => 'has-tooltip', 149 - 'meta' => array( 150 - 'tip' => $this->renderCommitTooltip($commit, $handles), 151 - 'align' => 'E', 152 - 'size' => 600, 155 + if ($commit) { 156 + $commit_link = javelin_tag( 157 + 'a', 158 + array( 159 + 'href' => $commit->getURI(), 160 + 'sigil' => 'has-tooltip', 161 + 'meta' => array( 162 + 'tip' => $this->renderCommitTooltip($commit, $handles), 163 + 'align' => 'E', 164 + 'size' => 600, 165 + ), 153 166 ), 154 - ), 155 - $commit->getLocalName()); 167 + $commit->getLocalName()); 168 + } else { 169 + $commit_link = null; 170 + } 156 171 157 172 $info = array( 158 173 $author_link, ··· 180 195 ); 181 196 } 182 197 183 - $epoch = $commit->getEpoch(); 198 + if ($commit) { 199 + $epoch = $commit->getEpoch(); 200 + } else { 201 + $epoch = 0; 202 + } 203 + 184 204 $epochs[] = $epoch; 185 205 186 206 $data = array(