# false positives from git diff-index when used with --git-dir

3 messages from 2010-10-14 to 2010-10-14. Participants: Alexander Gladysh, Jeff King.
Thread: https://gitlist.dev/t/25447

## Alexander Gladysh, 2010-10-14 14:40

Subject: false positives from git diff-index when used with --git-dir
Message-ID: <AANLkTimyeE=OLdC0Zzdnidr_dssFfkMzS+r_39dYUVxz@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimyeE%3DOLdC0Zzdnidr_dssFfkMzS%2Br_39dYUVxz%40mail.gmail.com

```
Hi, list!

$ git --version
git version 1.7.3.1

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 10.10
Release:	10.10
Codename:	maverick

I'm *sometimes* (once in about ten times I use it -- repository
changes between invocations of course) getting false positives from
git diff-index when I invoke git from another directory:

git --git-dir=path/to/.git --work-tree=path/to update-index -q --refresh
git --git-dir=path/to/.git --work-tree=path/to diff-index --exit-code
--quiet HEAD

This is *really* annoying and really kills the benifits from my
workflow automation scripts.

Unfortunately I can't find a reproducible use case for this bug.

Is there anything I can do to help catch it?

Thanks,
Alexander.

```

## Jeff King, 2010-10-14 17:02

Subject: Re: false positives from git diff-index when used with --git-dir
Message-ID: <20101014170227.GA14429@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20101014170227.GA14429%40sigill.intra.peff.net
In-Reply-To: <AANLkTimyeE=OLdC0Zzdnidr_dssFfkMzS+r_39dYUVxz@mail.gmail.com>

```
On Thu, Oct 14, 2010 at 06:40:51PM +0400, Alexander Gladysh wrote:

> I'm *sometimes* (once in about ten times I use it -- repository
> changes between invocations of course) getting false positives from
> git diff-index when I invoke git from another directory:
> 
> git --git-dir=path/to/.git --work-tree=path/to update-index -q --refresh
> git --git-dir=path/to/.git --work-tree=path/to diff-index --exit-code
> --quiet HEAD
> 
> This is *really* annoying and really kills the benifits from my
> workflow automation scripts.
> 
> Unfortunately I can't find a reproducible use case for this bug.
> 
> Is there anything I can do to help catch it?

Can it reproduce over a large number of trials? I.e., something like:

  while true; do
    git ... update-index ...
    git ... diff-index ... || echo failed
  done

If so, try adding a "sleep 1" between the two commands. If that fixes
it, it implies a race condition in git.

You could also try running under valgrind to see if there are any bad
memory accesses, which could also produce intermittent buggy behavior.

-Peff

```

## Alexander Gladysh, 2010-10-14 17:20

Subject: Re: false positives from git diff-index when used with --git-dir
Message-ID: <AANLkTimqvmecpt_j=HqHF1tircO5bPJHtRW-ePQ-wE+T@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimqvmecpt_j%3DHqHF1tircO5bPJHtRW-ePQ-wE%2BT%40mail.gmail.com
In-Reply-To: <20101014170227.GA14429@sigill.intra.peff.net>

```
On Thu, Oct 14, 2010 at 21:02, Jeff King <peff@peff.net> wrote:
> On Thu, Oct 14, 2010 at 06:40:51PM +0400, Alexander Gladysh wrote:

>> I'm *sometimes* (once in about ten times I use it -- repository
>> changes between invocations of course) getting false positives from
>> git diff-index when I invoke git from another directory:

>> git --git-dir=path/to/.git --work-tree=path/to update-index -q --refresh
>> git --git-dir=path/to/.git --work-tree=path/to diff-index --exit-code
>> --quiet HEAD

>> This is *really* annoying and really kills the benifits from my
>> workflow automation scripts.

>> Unfortunately I can't find a reproducible use case for this bug.

>> Is there anything I can do to help catch it?

> Can it reproduce over a large number of trials? I.e., something like:

>  while true; do
>    git ... update-index ...
>    git ... diff-index ... || echo failed
>  done

> If so, try adding a "sleep 1" between the two commands. If that fixes
> it, it implies a race condition in git.

No, I'm not able to reproduce it this way. (Perhaps some more complex
operations on git tree are required -- looks like it happens only if
tree was changed.)

> You could also try running under valgrind to see if there are any bad
> memory accesses, which could also produce intermittent buggy behavior.

Thanks, I'll try it.

It feels like a race condition somewhere. (Quite possibly even in my
automation tool -- since I'm not able to reproduce bug outside of it
-- if so, sorry for the noise.)

I'll try some more debugging and will get back to you if I will have
any new information.

Thank you,
Alexander.

```
