* describe with --git-dir and --dirty outside of the repo always says dirty
@ 2026-03-13 19:02 Thomas Braun
2026-03-13 20:29 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Braun @ 2026-03-13 19:02 UTC (permalink / raw)
To: GIT Mailing-list
When I do
git describe --dirty
in clean repo of git.git I get
v2.53.0-522-g67006b9db8
but when I do it from outside of the repo
cd ..
git --git-dir=git/.git describe --dirty
I get
v2.53.0-522-g67006b9db8-dirty
Curiously I can workaround the issue by directly passing the work-tree
git --work-tree=git --git-dir=git/.git describe --dirty
I suspect 2ed5c8e174 (describe: setup working tree for --dirty,
2019-02-03) has something to do with that.
Where should I start digging for a fix?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: describe with --git-dir and --dirty outside of the repo always says dirty
2026-03-13 19:02 describe with --git-dir and --dirty outside of the repo always says dirty Thomas Braun
@ 2026-03-13 20:29 ` Junio C Hamano
2026-03-16 8:22 ` Patrick Steinhardt
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2026-03-13 20:29 UTC (permalink / raw)
To: Thomas Braun; +Cc: GIT Mailing-list
Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:
> When I do
>
> git describe --dirty
>
> in clean repo of git.git I get
>
> v2.53.0-522-g67006b9db8
>
> but when I do it from outside of the repo
>
> cd ..
> git --git-dir=git/.git describe --dirty
"--git-dir" tells git "I am at the root of the working tree, but the
git directory that you usually find at ".git" (or a parent directory
of where we are) is not where you expect but somewhere else, so I am
telling you where it is with this argument.
So if you are not at the root of the working tree for that working
tree, "git --git-dir=git/.git diff" would report that you have a ton
of changes to working tree files, and "describe" would report that
your working tree is dirty.
In other words, working as intended.
You can tell where the working tree is (instead of telling the
command that you are at the root of the working tree, when you are
not), with the "--work-tree" option.
$ git --git-dir=git/.git --work-tree=git describe --dirty
> Where should I start digging for a fix?
Between the keyboard and the chair ;-)?
Perhaps documentation for "--git-dir", GIT_DIR, "--work-tree", and
GIT_WORK_TREE should be studied, and if you find that they are
lacking, that is something we can fix.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: describe with --git-dir and --dirty outside of the repo always says dirty
2026-03-13 20:29 ` Junio C Hamano
@ 2026-03-16 8:22 ` Patrick Steinhardt
2026-03-18 17:33 ` Thomas Braun
0 siblings, 1 reply; 4+ messages in thread
From: Patrick Steinhardt @ 2026-03-16 8:22 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Thomas Braun, GIT Mailing-list
On Fri, Mar 13, 2026 at 01:29:29PM -0700, Junio C Hamano wrote:
> Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:
>
> > When I do
> >
> > git describe --dirty
> >
> > in clean repo of git.git I get
> >
> > v2.53.0-522-g67006b9db8
> >
> > but when I do it from outside of the repo
> >
> > cd ..
> > git --git-dir=git/.git describe --dirty
>
> "--git-dir" tells git "I am at the root of the working tree, but the
> git directory that you usually find at ".git" (or a parent directory
> of where we are) is not where you expect but somewhere else, so I am
> telling you where it is with this argument.
>
> So if you are not at the root of the working tree for that working
> tree, "git --git-dir=git/.git diff" would report that you have a ton
> of changes to working tree files, and "describe" would report that
> your working tree is dirty.
>
> In other words, working as intended.
>
> You can tell where the working tree is (instead of telling the
> command that you are at the root of the working tree, when you are
> not), with the "--work-tree" option.
>
> $ git --git-dir=git/.git --work-tree=git describe --dirty
You can do that, but what you're probably looking for is `-C`:
$ git -C /path/to/git describe --dirty
As Junio pointed out, "--git-dir" has a different effect, and you
typically don't have to use it unless you're doing weird stuff.
Patrick
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: describe with --git-dir and --dirty outside of the repo always says dirty
2026-03-16 8:22 ` Patrick Steinhardt
@ 2026-03-18 17:33 ` Thomas Braun
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Braun @ 2026-03-18 17:33 UTC (permalink / raw)
To: Patrick Steinhardt, Junio C Hamano; +Cc: GIT Mailing-list
Am 16.03.2026 um 09:22 schrieb Patrick Steinhardt:
> On Fri, Mar 13, 2026 at 01:29:29PM -0700, Junio C Hamano wrote:
>> Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:
>>
>>> When I do
>>>
>>> git describe --dirty
>>>
>>> in clean repo of git.git I get
>>>
>>> v2.53.0-522-g67006b9db8
>>>
>>> but when I do it from outside of the repo
>>>
>>> cd ..
>>> git --git-dir=git/.git describe --dirty
>> "--git-dir" tells git "I am at the root of the working tree, but the
>> git directory that you usually find at ".git" (or a parent directory
>> of where we are) is not where you expect but somewhere else, so I am
>> telling you where it is with this argument.
>>
>> So if you are not at the root of the working tree for that working
>> tree, "git --git-dir=git/.git diff" would report that you have a ton
>> of changes to working tree files, and "describe" would report that
>> your working tree is dirty.
>>
>> In other words, working as intended.
>>
>> You can tell where the working tree is (instead of telling the
>> command that you are at the root of the working tree, when you are
>> not), with the "--work-tree" option.
>>
>> $ git --git-dir=git/.git --work-tree=git describe --dirty
> You can do that, but what you're probably looking for is `-C`:
>
> $ git -C /path/to/git describe --dirty
>
> As Junio pointed out, "--git-dir" has a different effect, and you
> typically don't have to use it unless you're doing weird stuff.
Thanks both Junio and Patrick. The documentation is not lacking and
fully explains
that -C is the way to go. I should have checked first.
My lameish excuse for originally using --git-dir is that -C which was
added in
44e1e4d67d (git: run in a directory given with -C option, 2013-09-09)
was too
new back then I added the code originally in 2014.
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-18 17:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 19:02 describe with --git-dir and --dirty outside of the repo always says dirty Thomas Braun
2026-03-13 20:29 ` Junio C Hamano
2026-03-16 8:22 ` Patrick Steinhardt
2026-03-18 17:33 ` Thomas Braun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox