static function id_for_pathspec($pathspec)
{
if (is_string($pathspec)) {
return trim(git::exec('rev-parse ' . escapeshellarg(':' . $pathspec)));
}
if (!is_array($pathspec)) {
throw new InvalidArgumentException('$pathspec is ' . gettype($pathspec));
}
# array
$pathspec_to_id = array();
foreach ($pathspec as $k => $s) {
$pathspec[$k] = escapeshellarg(':' . $s);
}
$lines = explode("\n", trim(git::exec('rev-parse ' . implode(' ', $pathspec))));
$i = 0;
foreach ($pathspec as $s) {
$pathspec_to_id[$s] = $lines[$i++];
}
return $pathspec_to_id;
}