Subject: Re: [PATCH 2/3] t1301-*.sh: Fix the 'forced modes' test on cygwin

From: Ramsay Jones <[email-masked]>
Date: Sat, 18 Jun 2011 20:04:15 +0100

Johannes Sixt wrote:
> BTW, it seems the patch fixes a bug when the two config parameters are
> not assigned a value: the initialization looks like this[*]:
> 
> static int native_stat = 1;
> static int core_filemode;
> 
> i.e., the default value of core.filemode seen by compat/cygwin.c is
> actually false, and the fast native l/stat would be used, contrary to
> the documentation. Am I missing something?

No, that is indeed a bug. See commit 7974843 (compat/cygwin.c: make
runtime detection of lstat/stat lessor impact, 23-10-2008).

That commit "taught" me to always change the core.filemode key set up
by git-init by changing the value ("false" -> "true"), *not* by simply
deleting that line in .git/config. Otherwise, you end up with the
"trust_executable_bit" (aka core.filemode) set to 1 and core_filemode
set to 0. This leads to yet more schizophrenic behaviour; for example,
in my cygwin git repo:

    $ git diff-files -p
    $ vim .git/config # remove the core.filemode key
    $ git diff-files -p
    diff --git a/.gitattributes b/.gitattributes
    diff --git a/.gitignore b/.gitignore
    diff --git a/.mailmap b/.mailmap
    diff --git a/COPYING b/COPYING
    diff --git a/Documentation/.gitattributes b/Documentation/.gitattributes
    diff --git a/Documentation/.gitignore b/Documentation/.gitignore
    diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
    ...
    diff --git a/check-builtins.sh b/check-builtins.sh
    old mode 100755
    new mode 100644
    diff --git a/check-racy.c b/check-racy.c
    diff --git a/check_bindir b/check_bindir
    old mode 100755
    new mode 100644
    diff --git a/color.c b/color.c
    ...
    diff --git a/xdiff/xutils.c b/xdiff/xutils.c
    diff --git a/xdiff/xutils.h b/xdiff/xutils.h
    diff --git a/zlib.c b/zlib.c
    $ git diff-files -p | wc -l
    3438
    $ git diff-files -p | grep '^old mode' | wc -l
    641
    $ vim .git/config # put "core.filemode true" back in
    $ git diff-files -p
    $

I had a patch in my cygwin repo which initialized core_filemode to 1
for ages, but never remembered to submit it. (I can't find it anymore,
so I must have deleted that branch). Not that I actually ran a git
with that patch applied.

ATB,
Ramsay Jones