# git-diff: unable to turn off diff.autorefreshindex with command line switch

3 messages from 2016-01-21 to 2016-01-22. Participants: Andrew Stewart, Jeff King.
Thread: https://gitlist.dev/t/41235

## Andrew Stewart, 2016-01-21 10:29

Subject: git-diff: unable to turn off diff.autorefreshindex with command line switch
Message-ID: <4432B7DA-921D-4D1C-8DC5-55A4E3722F73@airbladesoftware.com>
URL: https://gitlist.dev/e/4432B7DA-921D-4D1C-8DC5-55A4E3722F73%40airbladesoftware.com

```
Hello,

I am seeing unexpected behaviour on my system with git-diff and stat-only changes: diff.autorefreshindex=0 only works when in a repo's config (./.git/config); it doesn't work via a -c switch.  Conversely -c diff.autorefreshindex=1 does indeed override a 0 setting in the repo's config.

# First I remove all my normal configs.
$ mv ~/.git* ~/stuff/

# Now some setup.
$ mkdir foo && cd foo
$ git init
$ echo 123 > README
$ git commit -am 'initial'
[master (root-commit) 92e793c] initial
 ...[stuff about name and email address being auto-configured]...
 1 file changed, 1 insertion(+)
 create mode 100644 README
$ touch README

# Now the strange behaviour: no output from the next command
$ git -c diff.autorefreshindex=0 diff --raw -- README

$ cat .git/config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true

$ echo -e "[diff]\n  autorefreshindex = 0" >> .git/config
$ touch README

# Next command works as expected.
$ git diff --raw -- README
:100644 100644 190a180... 0000000... M  README

# Next command produces no output as expected
$ git -c diff.autorefreshindex=1 diff --raw -- README

I get this with both git v2.6.4 and v2.7.0 on my OS X 10.11.2.  I tried it on another system (Ubuntu 12.04 LTS, git 1.7.9.5) and everything worked as expected.  Somebody else tried it on their OS X 10.11.2 (as well as 10.10.something) with git 2.5.4 and everything worked as expected.

Any help would be much appreciated.  Thanks in advance!

Yours,
Andrew Stewart

```

## Jeff King, 2016-01-21 21:38

Subject: Re: git-diff: unable to turn off diff.autorefreshindex with command line switch
Message-ID: <20160121213801.GB6664@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20160121213801.GB6664%40sigill.intra.peff.net
In-Reply-To: <4432B7DA-921D-4D1C-8DC5-55A4E3722F73@airbladesoftware.com>

```
On Thu, Jan 21, 2016 at 10:29:49AM +0000, Andrew Stewart wrote:

> # Now the strange behaviour: no output from the next command
> $ git -c diff.autorefreshindex=0 diff --raw -- README

I can't reproduce here (v2.7.0, Linux).

But note that your whole test is going to be racy, and possibly depend
on the resolution of your filesystem's timestamps. Did you run your test
as a single script, where the initial index write and the `touch` may
happen in the same second? If so, trying running it slowly by hand,
or inserting "sleep 1" between the commands.

-Peff

```

## Andrew Stewart, 2016-01-22 14:12

Subject: Re: git-diff: unable to turn off diff.autorefreshindex with command line switch
Message-ID: <5BAA7C36-0059-4F0B-96B6-7B6E66D7C315@airbladesoftware.com>
URL: https://gitlist.dev/e/5BAA7C36-0059-4F0B-96B6-7B6E66D7C315%40airbladesoftware.com
In-Reply-To: <20160121213801.GB6664@sigill.intra.peff.net>

```
> On 21 Jan 2016, at 9:38 pm, Jeff King <peff@peff.net> wrote:
> But note that your whole test is going to be racy, and possibly depend
> on the resolution of your filesystem's timestamps. Did you run your test
> as a single script, where the initial index write and the `touch` may
> happen in the same second? If so, trying running it slowly by hand,
> or inserting "sleep 1" between the commands.

I ran my tests by hand, taking more than 1s between commands.

I also used `stat README` and `ls -l README` on occasion to confirm that `touch` was updating the file's timestamps.

-- Andrew Stewart
```
