Web lists-archives.com

git describe --dirty doesn't work with --work-tree

In a script of mine I want to describe HEAD without changing the
current directory, so I specify --git-dir and --work-tree. But it
appears the --dirty check doesn't consider the --work-tree value.

Here's a simplified example (on macOS 10.14.1):

$ git version
git version 2.20.1
$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in /Users/example/test/.git/
$ touch test
$ git add test
$ git commit -m "initial commit"
[master (root-commit) 9fc4511] initial commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test
$ git describe --all --dirty
$ cd ..
$ git --git-dir test/.git --work-tree test describe --all --dirty