The below PHP generates a cachefile used to display a GIT changelog.
(Because I didn’t have the power to get GIT installed onto the production server…)
<? $cachedir = "./cache/"; $cachefile = $cachedir . 'gitlog.txt'; if ( 'TRUE' == $devServer) { // check to see if cache directory exists - if not - make it if (!is_dir("$cachedir")) { mkdir("$cachedir", 0777, true); } // Start the output buffer ob_start(); // Use git log to display...(//http://opensource.apple.com/source/Git/Git-19/src/git-htmldocs/pretty-formats.txt) echo shell_exec('git log --pretty=format:"<hr><p><small><code>%h</code> %n%an, %ad</small></p><h4>%s</h4><pre>%b</pre>"'); // Now the script has run, generate a new cache file $fp = @fopen($cachefile, 'w'); // save the contents of output buffer to the file @fwrite($fp, ob_get_contents()); @fclose($fp); // Clean out the buffer ob_end_clean(); } echo file_get_contents("$cachefile"); ?>
If the following simple script in your repo directory doesn’t do it you may need to explicitly add git to you PATH. Even if it’s installed and running fine – PHP may not be able to find it.
Jump into Terminal sudo ln -s /usr/local/git/bin/git /usr/bin/git
https://groups.google.com/forum/?fromgroups=#!topic/symfony2/kF3aQ3ZWb88
Alternatively you may want to try this simple trick to reinstall command line tools using Xcode and see it that works (Xcode -> Preferences -> Downloads -> Command Line Tools -> Install)
http://www.hongkiat.com/blog/mountain-lion-git-fix/
Alternative issue that causes blank output: http://www.php.net/manual/en/function.shell-exec.php#106250
Last updated on 5th September 2018
Leave a Reply