Changeset View
Changeset View
Standalone View
Standalone View
src/parser/ArcanistDiffParser.php
Show First 20 Lines • Show All 1,304 Lines • ▼ Show 20 Lines | foreach ($filedata as $path => $data) { | ||||
$imagechanges[$path]->setCurrentFileData($data); | $imagechanges[$path]->setCurrentFileData($data); | ||||
} | } | ||||
$this->changes = $changes; | $this->changes = $changes; | ||||
} | } | ||||
/** | /** | ||||
* Split the paths on a "diff --git" line into old and new paths. This | * Extracts the common filename from two strings with differing path | ||||
* is difficult because they may be ambiguous if the files contain spaces. | * prefixes as found after `diff --git`. These strings may be | ||||
* quoted; if so, the filename is returned unescaped. The prefixes | |||||
* default to "a/" and "b/", but may be any string -- or may be | |||||
* entierly absent. This function may return "null" if the hunk | |||||
* represents a file move or copy, and with pathological renames may | |||||
* return an incorrect value. Such cases are expected to be | |||||
* recovered by later rename detection codepaths. | |||||
* | * | ||||
* @param string Text from a diff line after "diff --git ". | * @param string Text from a diff line after "diff --git ". | ||||
* @return pair<string, string> Old and new paths. | * @return string Filename being altered, or null for a rename. | ||||
*/ | */ | ||||
public static function extractGitCommonFilename($paths) { | public static function extractGitCommonFilename($paths) { | ||||
$matches = null; | $matches = null; | ||||
$paths = rtrim($paths, "\r\n"); | $paths = rtrim($paths, "\r\n"); | ||||
// Try the exact same string twice in a row separated by a | // Try the exact same string twice in a row separated by a | ||||
// space, with an optional prefix. This can hit a false | // space, with an optional prefix. This can hit a false | ||||
// positive for moves from files like "old file old" to "file", | // positive for moves from files like "old file old" to "file", | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |