threads / discuss / 50320

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

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

## tl;dr

One message between Jan 25, 2019 and Jan 25, 2019.

replies: 0people: 1as markdown or json

Blixt· Jan 25, 2019, 14:05 UTC · lore

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
heads/master
$ cd ..
$ git --git-dir test/.git --work-tree test describe --all --dirty
heads/master-dirty

← back to recent threads