git describe --dirty doesn't work with --work-tree
- From
- Blixt <me@blixt.nyc>
- Date
- Jan 25, 2019, 14:05 UTC
- Message-ID
- <CAFYJ4vur8KUbvnPaq2McR874K6o5YS6pCkKnihdwN758CKkwng@mail.gmail.com>
- In-Reply-To
- <CAFYJ4vvGhwxd5wTq-yYeOy6Hq-GpCsTy6=jG-LoHn2mShM4_NQ@mail.gmail.com>
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