title: Can git pre-receive hooks evaluate the incoming commit?
body: <p>I'm trying to write a server side pre-receive git hook to evaluate commits as they are being pushed. </p>
  
  <p>According to the <a href="https://stackoverflow.com/questions/22491942/how-can-you-block-git-commits-from-invalid-users">answers here</a>, this should easily be possible by searching git log and filtering out what I want with 'format:'. </p>
  
  <p>I've created the following pre-commit script. </p>
  
  <pre><code>#!/bin/bash
  
  set -x #for debugging, TODO: remove
  echo "parameters are" $@
  echo "1 is " $1
  
  #List of banned users
  bannedusers=( root )
  
  author_name=$(git show --pretty=oneline --pretty=format:%an | head -n1)
  author_email=$(git show --pretty=oneline --pretty=format:%ae | head -n1)
  
  committer_name=$(git show --pretty=oneline --pretty=format:%cn | head -n1)
  committer_email=$(git show --pretty=oneline --pretty=format:%ce | head -n1)
  
  commit_users=( "${author_name}" "${committer_name}" )
  
  
    for acommituser in "${commit_users[@]}"
    do
      :
      echo $acommituser #for debugging, TODO: remove
      for abanneduser in "${bannedusers[@]}"
      do
        :
          echo $abanneduser #for debugging, TODO: remove
          if [[ $abanneduser == $acommituser ]]; then
           echo "################################################################"
           echo "Commits from $abanneduser are not allowed"
           echo "git config user.name bob builder --replace-all"
           echo "git config user.email bob@aol.com"
           echo "git commit --amend --reset-author"
           echo "################################################################"
           exit 1
          fi
      done
    done
  </code></pre>
  
  <p>I find that when I run <code>git show</code> or <code>git log</code> on the server, the results are for the <em>current</em> HEAD, whereas I want to query the <em>incoming</em> commit. </p>
  
  <p>How could I modify this script to run <code>git log</code> or <code>git show</code> on the 'not-yet-recieved' commit? </p>