Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>shell_exec</code> is going to return <code>NULL</code> if the command fails. This is almost certainly happening... the question is why. You aren't going to be able to find out using <code>shell_exec</code>.</p> <p>I'd recommend instead using exec, so you can at least figure out the status of the call and what's going wrong.</p> <p><a href="http://www.php.net/manual/en/function.exec.php" rel="nofollow noreferrer">http://www.php.net/manual/en/function.exec.php</a></p> <p>This will allow you to setup some vars that will be populated with the return values of the system's internal os call.</p> <pre><code>$shell_output = array(); $status = NULL; if($_GET['action']=='add'){ $output = shell_exec('git add *',$shell_output,$status); print_r($shell_output) print_r($status); } if($_GET['action']=='commit'){ $output = shell_exec('git commit -m "'.$_POST["txt"].'" ',$shell_output,$status); print_r($shell_output) print_r($status); } </code></pre> <p>My guess is you have a problem with permissions. A <code>commit</code> in git requires write permission to that directory's '.git' folder.</p> <p>Also, make sure you are operating in the proper directory! The apache user that is running the PHP instance may or may not be already <code>cd</code>ed to the right folder where the repo is. You may need to add a <code>cd path_to_repo &amp;&amp; git commit</code> to your command to first move to the right directory. I'd first debug this with absolute paths.</p> <p>Just a word of advice as well... if you are trying to set up a PHP based git client, you are going to have to handle a ton of fail cases, one of which is readily apparent in this code... attempting a commit when no new files have been modified. I'd encourage you to look at community solutions if you need to be concerned with these cases:</p> <p><a href="https://stackoverflow.com/questions/9284283/is-there-a-good-php-git-client-with-http-support">Is there a good php git client with http support?</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload