title: Git "push --delete" blocked remotely by update hook
body: <p>I need a way to delete Git repository branches more conveniently cause an `update hook' is blocking them:</p>
  
  <h3>Command</h3>
  
  <pre class="lang-none prettyprint-override"><code>git push -v -f --no-verify --delete origin test_branch
  </code></pre>
  
  <h3>Output</h3>
  
  <pre class="lang-none prettyprint-override"><code>remote: fatal: Not a valid commit name 0000000000000000000000000000000000000000
  remote: error: hook declined to update refs/heads/test_branch
  </code></pre>
  
  <p>I'm currently disabling the update hook temporarily, performing the delete, and then restoring the hook, so I'm looking for suggestions for something better, even perhaps altering the Perl Git hook.</p>
  
  <p>I don't know anything about Perl or Git hooks, so I have these questions</p>
  
  <ol>
  <li><p>I can't give a message to the <code>push</code> action. What is the best way to achieve something like this?</p></li>
  <li><p>Is there any way to get the <code>push --delete</code> event from the hook?</p>
  
  <p>Something like </p>
  
  <pre class="lang-none prettyprint-override"><code>if ${push --delete} then skip hook checks
  </code></pre></li>
  <li><p>Is there any way to create a custom parameter to the <code>push</code> operation in order to skip the hook? Something like</p>
  
  <pre class="lang-none prettyprint-override"><code>if command line contains --imgod then skip hook checks
  </code></pre></li>
  </ol>
  
  <p>I'm totally groping in the dark.</p>
  
  <p>This is the <code>update</code> hook definition from the Git documentation</p>
  
  <blockquote>
    <p><strong>UPDATE HOOK</strong> 
    This hook is invoked by git-receive-pack on the remote repository, which happens when a git push is done on a local
    repository. Just before updating the ref on the remote repository, the
    update hook is invoked. Its exit status determines the success or
    failure of the ref update.</p>
    
    <p>The hook executes once for each ref to be updated, and takes three
    parameters:</p>
    
    <ul>
    <li><p>the name of the ref being updated,</p></li>
    <li><p>the old object name stored in the ref,</p></li>
    <li><p>and the new object name to be stored in the ref</p></li>
    </ul>
    
    <p>A zero exit from the update hook allows the ref to be updated. Exiting
    with a non-zero status prevents git-receive-pack from updating that
    ref.</p>
    
    <p>This hook can be used to prevent forced update on certain refs by
    making sure that the object name is a commit object that is a
    descendant of the commit object named by the old object name. That is,
    to enforce a "fast-forward only" policy.</p>
    
    <p>It could also be used to log the old..new status. However, it does not
    know the entire set of branches, so it would end up firing one e-mail
    per ref when used naively, though. The post-receive hook is more
    suited to that.</p>
    
    <p>In an environment that restricts the users' access only to git
    commands over the wire, this hook can be used to implement access
    control without relying on filesystem ownership and group membership.
    See git-shell[1] for how you might use the login shell to restrict the
    user’s access to only git commands.</p>
    
    <p>Both standard output and standard error output are forwarded to git
    send-pack on the other end, so you can simply echo messages for the
    user.</p>
    
    <p>The default update hook, when enabled—​and with hooks.allowunannotated
    config option unset or set to false—​prevents unannotated tags to be
    pushed.</p>
  </blockquote>
  
  <p><strong>ANSWER:</strong></p>
  
  <p>i found a way to catch the branch deletion event into the update hook and to skip the logic of the hook in all the other cases:</p>
  
  <pre class="lang-none prettyprint-override"><code>zero="0000000000000000000000000000000000000000"
  if [ "$refname" == "refs/heads/*"] &amp;&amp; [ "$newrev" == "$zero" ]; 
  then
        exit 0
  else
        perform_your_checks()
  fi
  </code></pre>
  
  <p>more info can be found in the update.sample GIT template.</p>