title: Force git commit when staging is empty, but pre-commit hook will add files
body: <p>Bit of a curly one that I haven't been able to find the answer to. I have a pre-commit hook for git which mysqldumps the database, and stages the file for committing.</p>
  
  <p>I'm running Drupal for a project, and thus, quite a bit of config is done through the interface and is stored in the database, and obviously, I'm keen to capture point in time milestones in version control.</p>
  
  <p>Here's the basic cut down test that I'm trying this with:</p>
  
  <pre><code>#!/bin/bash
  
  #commit database as point-in-time
  SITE_PATH="/data/site.com"
  cd $SITE_PATH
  
  FILE_NAME="db/site.sql"
  $(mysqldump --skip-extended-insert --skip-dump-date db_name &gt; $FILE_NAME)
  
  #add changed file to commit
  $(git add $FILE_NAME)
  </code></pre>
  
  <p>The issue is that if there are no files to be staged, the pre-commit script runs, but the commit isn't completed. If you run <code>echo $?</code> afterwards, <code>git commit</code> returns an exit code of 1 (because there were no files initially in staging). Running <code>git status</code> shows that the db dump is now staged ready for commit though.</p>
  
  <p>The commit works if I have any other file added to staging before running the commit.</p>
  
  <p>I can obviously easily write a wrapper that does what I want and then calls <code>git commit</code> at the end after everything has been staged in advance, but can anyone shed some light on best practices for this situation?</p>