Differential D21511 Diff 51200 src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php
| Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | private function loadGitCommitRef() { | ||||
| if (version_compare($git_version, '1.7.2', '>=')) { | if (version_compare($git_version, '1.7.2', '>=')) { | ||||
| $body_format = '%B'; | $body_format = '%B'; | ||||
| $split_body = false; | $split_body = false; | ||||
| } else { | } else { | ||||
| $body_format = '%s%x00%b'; | $body_format = '%s%x00%b'; | ||||
| $split_body = true; | $split_body = true; | ||||
| } | } | ||||
| // Even though we pass --encoding here, git doesn't always succeed, so | $argv = array(); | ||||
| // we try a little harder, since git *does* tell us what the actual encoding | |||||
| // is correctly (unless it doesn't; encoding is sometimes empty). | $argv[] = '-n'; | ||||
| list($info) = $repository->execxLocalCommand( | $argv[] = '1'; | ||||
| 'log -n 1 --encoding=%s --format=%s %s --', | |||||
| 'UTF-8', | $argv[] = '--encoding=UTF-8'; | ||||
| $argv[] = sprintf( | |||||
| '--format=%s', | |||||
| implode( | implode( | ||||
| '%x00', | '%x00', | ||||
| array( | array( | ||||
| '%e', | '%e', | ||||
| '%cn', | '%cn', | ||||
| '%ce', | '%ce', | ||||
| '%an', | '%an', | ||||
| '%ae', | '%ae', | ||||
| '%T', | '%T', | ||||
| '%at', | '%at', | ||||
| $body_format, | $body_format, | ||||
| // The "git log" output includes a trailing newline. We want to | // The "git log" output includes a trailing newline. We want to | ||||
| // faithfully capture only the exact text of the commit message, | // faithfully capture only the exact text of the commit message, | ||||
| // so include an explicit terminator: this makes sure the exact | // so include an explicit terminator: this makes sure the exact | ||||
| // body text is surrounded by "\0" characters. | // body text is surrounded by "\0" characters. | ||||
| '~', | '~', | ||||
| )), | ))); | ||||
| $this->identifier); | |||||
| // Even though we pass --encoding here, git doesn't always succeed, so | |||||
| // we try a little harder, since git *does* tell us what the actual encoding | |||||
| // is correctly (unless it doesn't; encoding is sometimes empty). | |||||
| list($info) = $repository->execxLocalCommand( | |||||
| 'log -n 1 %Ls %s --', | |||||
| $argv, | |||||
| gitsprintf('%s', $this->identifier)); | |||||
| $parts = explode("\0", $info); | $parts = explode("\0", $info); | ||||
| $encoding = array_shift($parts); | $encoding = array_shift($parts); | ||||
| foreach ($parts as $key => $part) { | foreach ($parts as $key => $part) { | ||||
| if ($encoding) { | if ($encoding) { | ||||
| $part = phutil_utf8_convert($part, 'UTF-8', $encoding); | $part = phutil_utf8_convert($part, 'UTF-8', $encoding); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines | |||||