@matheusbsbs / matheus-bagliano / commits / 7faee6b8de
Fork 0

compat/cygwin.c - Use cygwin's stat if core.filemode == true

Cygwin's POSIX emulation allows use of core.filemode true, unlike native Window's implementation of stat / lstat, and Cygwin/git users who have configured core.filemode true in various repositories will be very unpleasantly surprised to find that git is no longer honoring that option. So, this patch forces use of Cygwin's stat functions if core.filemode is set true, regardless of any other considerations. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mark Levedahl committed Oct 13, 2008 at 00:33 UTC 7faee6b8de836904227ee98dc3d2c4c75b0ef3a1
2 files changed +17 -5
Documentation/config.txt
+3 -1
@@ -124,7 +124,9 @@ core.ignoreCygwinFSTricks::
124 one hierarchy using Cygwin mount. If true, Git uses native Win32 API
125 whenever it is possible and falls back to Cygwin functions only to
126 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.
130
131 core.trustctime::
132 If false, the ctime differences between the index and the
compat/cygwin.c
+14 -4
@@ -91,22 +91,32 @@ static int cygwin_stat(const char *path, struct stat *buf)
91 * functions should be used. The choice is determined by core.ignorecygwinfstricks.
92 * Reading this option is not always possible immediately as git_dir may be
93 * 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.
96 */
97 static int native_stat = 1;
98 +extern int trust_executable_bit;
99
100 static int git_cygwin_config(const char *var, const char *value, void *cb)
101 {
99 - if (!strcmp(var, "core.ignorecygwinfstricks"))
102 + if (!strcmp(var, "core.ignorecygwinfstricks")) {
103 native_stat = git_config_bool(var, value);
101 - return 0;
104 + return 0;
105 + }
106 + return git_default_config(var, value, cb);
107 }
108
109 static int init_stat(void)
110 {
111 if (have_git_dir()) {
112 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 + }
120 return 0;
121 }
122 return 1;