diff --git a/scripts/gitadmin/rebuild_gitadmin.php b/scripts/gitadmin/rebuild_gitadmin.php index 80274fef4e..57fa75dbdb 100755 --- a/scripts/gitadmin/rebuild_gitadmin.php +++ b/scripts/gitadmin/rebuild_gitadmin.php @@ -166,55 +166,52 @@ function rebuildConfiguration($gitosis_root) { return true; } -function getGitCommand($repository, $need_workdir) { +function getGitCommand($repository) { $git_dir = realpath("$repository/.git"); $git = "git --git-dir='$git_dir'"; - if ($need_workdir) { - $git .= ' --work-tree='.realpath($repository); - } + $git .= ' --work-tree='.realpath($repository); return $git; } -function runGitCommand($repository, $need_workdir, $arguments, +function runGitCommand($repository, $arguments, &$output=null, &$return_var=null) { - $git = getGitCommand($repository, $need_workdir); + $git = getGitCommand($repository); $git .= " $arguments"; exec($git, $output, $return_var); return $return_var == 0; } -function runGitSshCommand($repository, $key, $need_workdir, $arguments, +function runGitSshCommand($repository, $key, $arguments, &$output=null, &$return_var=null) { $gitx_ssh = realpath(dirname(__FILE__) . "/gitx-ssh"); $abs_key = realpath($key); $git = "SSH_KEYFILE=$abs_key GIT_SSH=$gitx_ssh "; - $git .= getGitCommand($repository, $need_workdir); + $git .= getGitCommand($repository); $git .= " $arguments"; exec($git, $output, $return_var); return $return_var == 0; } function repositoryPull($repository, $key) { - return runGitSshCommand($repository, $key, false, 'pull'); + return runGitSshCommand($repository, $key, 'pull'); } function repositoryCommitAll($repository, $author, $message) { if (!runGitCommand( - $repository, true, - 'ls-files --other --exclude-standard', $untracked_files)) { + $repository, 'ls-files --other --exclude-standard', $untracked_files)) { return false; } if (count($untracked_files)) { $flat_files = join(' ', $untracked_files); - if (!runGitCommand($repository, true, "add $flat_files")) { + if (!runGitCommand($repository, "add $flat_files")) { return false; } } - runGitCommand($repository, true, "update-index -q --refresh", $output); - runGitCommand($repository, true, "diff-index --name-only HEAD --", $output); + runGitCommand($repository, "update-index -q --refresh", $output); + runGitCommand($repository, "diff-index --name-only HEAD --", $output); if (count($output)) { return runGitCommand( - $repository, true, "commit --author='$author' -a -m '$message'", $output); + $repository, "commit --author='$author' -a -m '$message'", $output); } return true; } @@ -243,5 +240,5 @@ if (!repositoryCommitAll( exit(1); } -runGitSshCommand($gitosis_root, $key, true, 'push origin master'); +runGitSshCommand($gitosis_root, $key, 'push origin master'); ?>