git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git-describe considers WC dirty incorrectly when using --git-dir

From
CPChris Pimlott <chris@pimlott.net>
Date
Mar 4, 2015, 19:47 UTC
Message-ID
<CACWYfsCO3O-x8zBsFXoSTFZ8GiaO6CpAszUHRtjM0dCp0Q8ogg@mail.gmail.com>

It seems that git-describe always thinks that working copy is dirty if you are not in the WC root and you explicitly specify the .git directory location using --git-dir:

  # set up test repo
  folio:~ chris$ mkdir repo && cd repo
  folio:repo chris$ mkdir text && echo hi > text/hi.txt
  folio:repo chris$ git init . && git add . && git commit -m "text/hi.txt"
  Initialized empty Git repository in /home/chris/repo/.git/
  [master (root-commit) c0edd63] text/hi.txt
  1 file changed, 1 insertion(+)
  create mode 100644 text/hi.txt
  # git-describe from non-root directory
  folio:repo chris$ cd text
  folio:text chris$ git describe --always --dirty
  c0edd63
  folio:text chris$ git --git-dir=../.git describe --always --dirty
  c0edd63-dirty
  folio:text chris$ git --git-dir=$(git rev-parse
--show-toplevel)/.git describe --always --dirty
  c0edd63-dirty
  # git-describe from root directory
  folio:repo chris$ cd ..
  folio:repo chris$ git describe --always --dirty
  c0edd63
  folio:repo chris$ git --git-dir=.git describe --always --dirty
  c0edd63
  folio:repo chris$ git --git-dir=$(git rev-parse
--show-toplevel)/.git describe --always --dirty
  c0edd63
Next: Junio C Hamano
Message 1 of 3 in “git-describe considers WC dirty incorrectly when using --git-dir”
  1. Chris PimlottMar 4, 2015
  2. Junio C HamanoMar 4, 2015
  3. Chris PimlottMar 4, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.