X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=compat%2Fcygwin.c;h=ebac1483929c798905e6558e0013e3de3d6abeb2;hb=1e2bba92d21d9c72d4a6816c3a98a22779856f9e;hp=423ff20b0ef88111acbb61bd590fe39a4504a93a;hpb=3aa615bc5d5348d732b5b1354cc3517a55b34a6f;p=git.git diff --git a/compat/cygwin.c b/compat/cygwin.c index 423ff20b0..ebac14839 100644 --- a/compat/cygwin.c +++ b/compat/cygwin.c @@ -91,13 +91,24 @@ static int cygwin_stat(const char *path, struct stat *buf) * functions should be used. The choice is determined by core.ignorecygwinfstricks. * Reading this option is not always possible immediately as git_dir may be * not be set yet. So until it is set, use cygwin lstat/stat functions. + * However, if core.filemode is set, we must use the Cygwin posix + * stat/lstat as the Windows stat fuctions do not determine posix filemode. + * + * Note that git_cygwin_config() does NOT call git_default_config() and this + * is deliberate. Many commands read from config to establish initial + * values in variables and later tweak them from elsewhere (e.g. command line). + * init_stat() is called lazily on demand, typically much late in the program, + * and calling git_default_config() from here would break such variables. */ static int native_stat = 1; +static int core_filemode; static int git_cygwin_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "core.ignorecygwinfstricks")) native_stat = git_config_bool(var, value); + else if (!strcmp(var, "core.filemode")) + core_filemode = git_config_bool(var, value); return 0; } @@ -105,8 +116,13 @@ static int init_stat(void) { if (have_git_dir()) { git_config(git_cygwin_config, NULL); - cygwin_stat_fn = native_stat ? cygwin_stat : stat; - cygwin_lstat_fn = native_stat ? cygwin_lstat : lstat; + if (!core_filemode && native_stat) { + cygwin_stat_fn = cygwin_stat; + cygwin_lstat_fn = cygwin_lstat; + } else { + cygwin_stat_fn = stat; + cygwin_lstat_fn = lstat; + } return 0; } return 1;