title: Why is `git describe -dirty` adding a `-dirty` suffix when describing a clean checkout?
body: <p>I have just discovered the <code>--dirty</code> option to <code>git describe</code> and it looks like it should do something very useful, i.e. append a suffix to the output of <code>git describe</code> when the working tree is dirty, however that doesn't seem to be the case on some of my repositories:</p>
  
  <pre><code>$ git status
  # On branch 8.30
  nothing to commit (working directory clean)
  $ git describe --dirty
  8.30rel-8-g9c1cbdb-dirty
  </code></pre>
  
  <p>I thought this might be because the working directory is dirty <em>relative to the tag</em>, but that doesn't seem to be the case either:</p>
  
  <pre><code>$ git status
  # On branch 1.4
  nothing to commit (working directory clean)
  $ git describe --tags --dirty --long
  1.4rel-0-gfedfe66-dirty
  </code></pre>
  
  <p>I used to make extensive use of <code>hg id</code> when I used to <a href="https://stackoverflow.com/q/2386440/42473">use Mercurial</a> and liked the fact that it's default behaviour was to add a <code>+</code> suffix to any commit hash it reported for a dirty repository, so have been looking out for a <code>git</code> equivalent since, but <code>git describe --dirty</code> doesn't appear to do what I would expect given the documentation:</p>
  
  <blockquote>
  <pre><code>   --dirty[=&lt;mark&gt;]
         Describe the working tree. It means describe HEAD and appends
         &lt;mark&gt; (-dirty by default) if the working tree is dirty.
  </code></pre>
  </blockquote>
  
  <p>Am I misunderstanding what <code>--dirty</code> should do, or am I not using it correctly?</p>
  
  <p>In case it makes any difference, all of the git repositories are deployed via <a href="http://www.eclipse.org/buckminster/" rel="nofollow noreferrer">buckminster</a> so there are no <em>submodules</em> involved and the filesystem is an <code>nfs</code> share.</p>
  
  <hr>
  
  <p><strong>Update:</strong> I have discovered a work around, but I have absolutely no idea how this could possibly be making a difference.</p>
  
  <p>If I run <code>git diff --quiet HEAD</code> on the repo then all of a sudden the <code>git describe</code> works as I expect:</p>
  
  <pre><code>$ git status
  # On branch 8.30
  nothing to commit (working directory clean)
  $ git describe --dirty
  8.30rel-8-g9c1cbdb-dirty
  $ git diff --quiet HEAD
  $ git describe --dirty
  8.30rel-8-g9c1cbdb
  </code></pre>
  
  <p>I also spotted that when <code>git describe</code> was reporting the repository as <code>dirty</code> then <code>gitk</code> also showed "Local uncommitted changes, not checked in to index" and then listed each file in the working directory, but with no diffs against them, just the <code>---- filename ----</code> lines.</p>
  
  <hr>
  
  <p><strong>Further update:</strong> As this continued to be a problem, I eventually wrote a <code>git-describe-dirty</code> script, which starts by running <code>git describe --dirty</code> but if it finds the repository to be dirty, runs <code>git update-index -q --refresh</code> before trying again and taking the second result.</p>
  
  <p>When iterating through hundreds of repositories, using <code>git describe-dirty</code> and only running the index update for a repository which initially indicates it is dirty saves a great deal of time compared to running <code>git update-index -q --refresh ; git describe --dirty</code> every time.</p>