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

Only show text encoding note in Differential if a change has hunks

Summary: Fixes T5503. We incorrectly render an encoding note for empty files. Only render an encoding note for text changes with at least one hunk.

Test Plan:
- Viewed empty file, no note.
- Viewed nonempty file with altered encoding, saw note.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T5503

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

+16 -9
+16 -9
src/applications/differential/render/DifferentialChangesetHTMLRenderer.php
··· 252 252 break; 253 253 } 254 254 255 - $encoding = $this->getOriginalCharacterEncoding(); 256 - if ($encoding != 'utf8' && ($file == DifferentialChangeType::FILE_TEXT)) { 257 - if ($encoding) { 258 - $messages[] = pht( 259 - 'This file was converted from %s for display.', 260 - phutil_tag('strong', array(), $encoding)); 261 - } else { 262 - $messages[] = pht( 263 - 'This file uses an unknown character encoding.'); 255 + // If this is a text file with at least one hunk, we may have converted 256 + // the text encoding. In this case, show a note. 257 + $show_encoding = ($file == DifferentialChangeType::FILE_TEXT) && 258 + ($changeset->getHunks()); 259 + 260 + if ($show_encoding) { 261 + $encoding = $this->getOriginalCharacterEncoding(); 262 + if ($encoding != 'utf8') { 263 + if ($encoding) { 264 + $messages[] = pht( 265 + 'This file was converted from %s for display.', 266 + phutil_tag('strong', array(), $encoding)); 267 + } else { 268 + $messages[] = pht( 269 + 'This file uses an unknown character encoding.'); 270 + } 264 271 } 265 272 } 266 273