<?php
header
('Content-type: text/plain');
$cwd getcwd();
if ((isset(
$_GET['r']))&&(ctype_alnum($_GET['r']))) {
    
$updatearg $_GET['r'];
} else {
    
$updatearg 'noupdate';
}
    
if (
$updatearg != 'noupdate') {
  echo 
"############### gitpull ###############\n";
  
system("cd $cwd ; git checkout master");
  
system("cd $cwd ; git pull");
  if (
strtolower($updatearg) != 'head') {
    
system("cd $cwd ; git checkout $updatearg");
  }
  echo 
"\n";
}

echo 
"############## git status ##############\n";
system('cd $cwd ; git status');
echo 
"\n";

echo 
"############## git branch ##############\n";
system('cd $cwd ; git branch');
echo 
"\n";

// validate "l" and make sure it's less than 1k (just to be safe)
if ((isset($_GET['l']))&&(is_numeric($_GET['l']))&&($_GET['l'] <= 1000)) {
    
$logarg $_GET['l'];
} else {
    
$logarg 3;
}
echo 
"############## git log (last $logarg entries) ##############\n";
system("cd $cwd ; git log --stat -$logarg");
echo 
"\n";