original_string: private function runGit($cmd, $setDirectories = true)
      {
          static $execAvailable;
          if (!isset($execAvailable)) {
              $safeMode = @ini_get('safe_mode');
              if (!empty($safeMode)) {
                  throw new UserMessageException(t("Safe-mode can't be on"));
              }
              if (!function_exists('exec')) {
                  throw new UserMessageException(t('exec() function is missing'));
              }
              if (in_array('exec', array_map('trim', explode(',', strtolower(@ini_get('disable_functions')))))) {
                  throw new UserMessageException(t('exec() function is disabled'));
              }
              $execAvailable = true;
          }
          $line = 'git';
          if ($setDirectories) {
              $line .= ' -C ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $this->getWorktreeDirectory()));
          }
          $line .= ' ' . $cmd . ' 2>&1';
          $rc = 1;
          $output = [];
          @exec($line, $output, $rc);
          if ($rc !== 0) {
              throw new UserMessageException(t('Command failed with return code %1$s: %2$s', $rc, implode("\n", $output)));
          }
  
          return $output;
      }
code: private function runGit($cmd, $setDirectories = true)
      {
          static $execAvailable;
          if (!isset($execAvailable)) {
              $safeMode = @ini_get('safe_mode');
              if (!empty($safeMode)) {
                  throw new UserMessageException(t("Safe-mode can't be on"));
              }
              if (!function_exists('exec')) {
                  throw new UserMessageException(t('exec() function is missing'));
              }
              if (in_array('exec', array_map('trim', explode(',', strtolower(@ini_get('disable_functions')))))) {
                  throw new UserMessageException(t('exec() function is disabled'));
              }
              $execAvailable = true;
          }
          $line = 'git';
          if ($setDirectories) {
              $line .= ' -C ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $this->getWorktreeDirectory()));
          }
          $line .= ' ' . $cmd . ' 2>&1';
          $rc = 1;
          $output = [];
          @exec($line, $output, $rc);
          if ($rc !== 0) {
              throw new UserMessageException(t('Command failed with return code %1$s: %2$s', $rc, implode("\n", $output)));
          }
  
          return $output;
      }
code_tokens: private function runGit ( $ cmd , $ setDirectories = true ) { static $ execAvailable ; if ( ! isset ( $ execAvailable ) ) { $ safeMode = @ ini_get ( 'safe_mode' ) ; if ( ! empty ( $ safeMode ) ) { throw new UserMessageException ( t ( "Safe-mode can't be on" ) ) ; } if ( ! function_exists ( 'exec' ) ) { throw new UserMessageException ( t ( 'exec() function is missing' ) ) ; } if ( in_array ( 'exec' , array_map ( 'trim' , explode ( ',' , strtolower ( @ ini_get ( 'disable_functions' ) ) ) ) ) ) { throw new UserMessageException ( t ( 'exec() function is disabled' ) ) ; } $ execAvailable = true ; } $ line = 'git' ; if ( $ setDirectories ) { $ line .= ' -C ' . escapeshellarg ( str_replace ( '/' , DIRECTORY_SEPARATOR , $ this -> getWorktreeDirectory ( ) ) ) ; } $ line .= ' ' . $ cmd . ' 2>&1' ; $ rc = 1 ; $ output = [ ] ; @ exec ( $ line , $ output , $ rc ) ; if ( $ rc !== 0 ) { throw new UserMessageException ( t ( 'Command failed with return code %1$s: %2$s' , $ rc , implode ( "\n" , $ output ) ) ) ; } return $ output ; }
docstring: Execute a git command.
  
  @param string $cmd
  @param bool $setDirectories
  
  @throws UserMessageException
  
  @return string[]
docstring_tokens: Execute a git command .