fork download
  1. <?php
  2.  
  3. $against = $argv[1];
  4.  
  5. $file_list = explode("\n", `/usr/bin/git diff --diff-filter=ACMR --name-only $against`);
  6.  
  7. foreach ($file_list as $file) {
  8. $file = trim($file);
  9. if (!empty($file) && preg_match('/^modules\/.+?.cpp$/', $file)) {
  10. $source = file_get_contents($file);
  11. $version = 1;
  12. $source = preg_replace_callback('/\$ModVer (\d+)\$/', function(array $matches) {
  13. $current_version = intval($matches[1]) + 1;
  14. $version = $current_version;
  15. return "\$ModVer $current_version$";
  16. }, $source);
  17. $source = preg_replace('/\$ModVer\$/m', '$ModVer 1$', $source);
  18. print "$file => version $version\n";
  19. file_put_contents($file, $source);
  20. system("/usr/bin/git add $file");
  21. }
  22. }
  23.  
Success #stdin #stdout #stderr 0.04s 24312KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Notice:  Undefined offset: 1 in /home/9ugG7d/prog.php on line 3
Not a git repository
To compare two paths outside a working tree:
usage: git diff [--no-index] <path> <path>