title: Determine relationship between commits
body: <p>In a linear history, two commits A and B can have one of three states:</p>
  
  <ul>
  <li>A and B are the same commit</li>
  <li>A strictly before B</li>
  <li>B strictly before A</li>
  </ul>
  
  <p>Git's nonlinear history allows for four additional options</p>
  
  <ul>
  <li>A and B share both a parent and child</li>
  <li>A and B share a parent but not a child</li>
  <li>A and B share a child but not a parent</li>
  <li>A and B share nothing</li>
  </ul>
  
  <p>I'm not sure how to achieve the last two without using graft points, but it <em>could</em> happen.</p>
  
  <p>What I'm unsure of how to accomplish is a determination of this relationship in a simple manner--at the moment I can only think of a somewhat odd <code>rev-list</code> and solution where one tests each case individually:</p>
  
  <pre><code>[[ "$a" = "$b" ]] &amp;&amp; echo "same"
  git rev-list "$b" | grep -q "$a" &amp;&amp; echo "a before b"
  git rev-list "$a" | grep -q "$b" &amp;&amp; echo "b before a"
  cat &lt;(git rev-list "$a") &lt;(git rev-list "$b") | sort | uniq -cd | grep -q 2 &amp;&amp; echo "A and B share parents"
  cat &lt;(git rev-list --children "$a") &lt;(git rev-list --children "$b") | sort | uniq -cd | grep -q 2 &amp;&amp; echo "A and B share children"
  </code></pre>
  
  <p>There has to be a better, gittier way of doing this, so what is it?</p>