Merge branch 'ml/cygwin-filemode'
authorJunio C Hamano <gitster@pobox.com>
Sun, 19 Oct 2008 23:07:02 +0000 (16:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 Oct 2008 23:07:02 +0000 (16:07 -0700)
* ml/cygwin-filemode:
compat/cygwin.c - Use cygwin's stat if core.filemode == true

Documentation/config.txt
compat/cygwin.c
index 5ba3ffa10f7ff8e2499b85a4ff1b375b2c482782..29369d051b1d8248b85ae177151a4ebaa79bce3b 100644 (file)
@@ -124,7 +124,9 @@ core.ignoreCygwinFSTricks::
        one hierarchy using Cygwin mount. If true, Git uses native Win32 API
        whenever it is possible and falls back to Cygwin functions only to
        handle symbol links. The native mode is more than twice faster than
-       normal Cygwin l/stat() functions. True by default.
+       normal Cygwin l/stat() functions. True by default, unless core.filemode
+       is true, in which case ignoreCygwinFSTricks is ignored as Cygwin's
+       POSIX emulation is required to support core.filemode.
 
 core.trustctime::
        If false, the ctime differences between the index and the
index 423ff20b0ef88111acbb61bd590fe39a4504a93a..f1967532bae87cbe3627b065083cc56ca0b64550 100644 (file)
@@ -91,22 +91,32 @@ 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 the trust_executable_bit is set, we must use the Cygwin posix
+ * stat/lstat as the Windows stat fuctions do not determine posix filemode.
  */
 static int native_stat = 1;
+extern int trust_executable_bit;
 
 static int git_cygwin_config(const char *var, const char *value, void *cb)
 {
-       if (!strcmp(var, "core.ignorecygwinfstricks"))
+       if (!strcmp(var, "core.ignorecygwinfstricks")) {
                native_stat = git_config_bool(var, value);
-       return 0;
+               return 0;
+       }
+       return git_default_config(var, value, cb);
 }
 
 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 (!trust_executable_bit && 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;