Skip to content

Commit 449acfa

Browse files
committed
Merge branch 'ml/cygwin-filemode'
* ml/cygwin-filemode: compat/cygwin.c - Use cygwin's stat if core.filemode == true
2 parents 94d2b85 + 7faee6b commit 449acfa

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Documentation/config.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ core.ignoreCygwinFSTricks::
124124
one hierarchy using Cygwin mount. If true, Git uses native Win32 API
125125
whenever it is possible and falls back to Cygwin functions only to
126126
handle symbol links. The native mode is more than twice faster than
127-
normal Cygwin l/stat() functions. True by default.
127+
normal Cygwin l/stat() functions. True by default, unless core.filemode
128+
is true, in which case ignoreCygwinFSTricks is ignored as Cygwin's
129+
POSIX emulation is required to support core.filemode.
128130

129131
core.trustctime::
130132
If false, the ctime differences between the index and the

compat/cygwin.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,32 @@ static int cygwin_stat(const char *path, struct stat *buf)
9191
* functions should be used. The choice is determined by core.ignorecygwinfstricks.
9292
* Reading this option is not always possible immediately as git_dir may be
9393
* not be set yet. So until it is set, use cygwin lstat/stat functions.
94+
* However, if the trust_executable_bit is set, we must use the Cygwin posix
95+
* stat/lstat as the Windows stat fuctions do not determine posix filemode.
9496
*/
9597
static int native_stat = 1;
98+
extern int trust_executable_bit;
9699

97100
static int git_cygwin_config(const char *var, const char *value, void *cb)
98101
{
99-
if (!strcmp(var, "core.ignorecygwinfstricks"))
102+
if (!strcmp(var, "core.ignorecygwinfstricks")) {
100103
native_stat = git_config_bool(var, value);
101-
return 0;
104+
return 0;
105+
}
106+
return git_default_config(var, value, cb);
102107
}
103108

104109
static int init_stat(void)
105110
{
106111
if (have_git_dir()) {
107112
git_config(git_cygwin_config, NULL);
108-
cygwin_stat_fn = native_stat ? cygwin_stat : stat;
109-
cygwin_lstat_fn = native_stat ? cygwin_lstat : lstat;
113+
if (!trust_executable_bit && native_stat) {
114+
cygwin_stat_fn = cygwin_stat;
115+
cygwin_lstat_fn = cygwin_lstat;
116+
} else {
117+
cygwin_stat_fn = stat;
118+
cygwin_lstat_fn = lstat;
119+
}
110120
return 0;
111121
}
112122
return 1;

0 commit comments

Comments
 (0)