title: block push of trivial merge to git server
body: <p>A while back I <a href="http://thread.gmane.org/gmane.comp.finance.mifos.devel/9491/focus=9597" rel="nofollow noreferrer">asked our developers to use rebase instead of merge before pushing</a>. Eliminating trivial merges makes for a much easier to follow commit graph (ie: gitk, git log).</p>
  
  <p>Sometimes folks still accidentally do trivial merges, then push. Does anyone have handy or have tips for writing a server-side hook that blocks trivial merges?</p>
  
  <p>By "trivial merge", I mean a merge without conflicts. <a href="http://mifos.git.sourceforge.net/git/gitweb.cgi?p=mifos/head;a=commit;h=c516520a9c37944c96162ffd85c00f68b81786a6" rel="nofollow noreferrer">Here's an example</a>, and <a href="https://stackoverflow.com/questions/1824264/what-is-a-trivial-merge-in-git/1824297#1824297">here's a better explanation of a trivial merge in git</a>.</p>
  
  <p><strong>Update Wed Nov 10 01:26:41 UTC 2010</strong>: great comments, all! Thank you.</p>
  
  <ul>
  <li>Consider the following: all I'm really asking folks to do is this:
  
  <ul>
  <li>if <code>git pull --ff-only</code> fails, do <code>git pull --rebase</code> instead of <code>git pull</code></li>
  </ul></li>
  <li>git.git only has one or two committers, right? In theory, it should be easy to follow the commit graph, but it looks pretty messy to me.</li>
  </ul>
  
  <p><strong>Update Thu Nov 11 23:49:35 UTC 2010</strong>:</p>
  
  <ul>
  <li><a href="https://gist.github.com/673438" rel="nofollow noreferrer">here's a gist with some in-progress work</a></li>
  <li>another idea is to prevent trivial merges on the client end, with a "git push" <a href="http://article.gmane.org/gmane.comp.version-control.git/92920" rel="nofollow noreferrer">wrapper</a></li>
  </ul>
  
  <p><strong>Update Wed Dec 15 18:34:52 UTC 2010</strong>:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/users/217284/adymitruk">adymitruk</a> is close! Just one case is still unresolved: non-trivial merges must still work.</li>
  <li>A rather complete <a href="https://gist.github.com/737842" rel="nofollow noreferrer">test suite</a> is available, check it out.</li>
  <li>I asked for help on a (the?) <a href="http://thread.gmane.org/gmane.comp.version-control.git/163788" rel="nofollow noreferrer">git mailing list</a>.</li>
  </ul>