git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Mark Levedahl <mlevedahl@gmail.com>
Date
Oct 11, 2008, 19:04 UTC
Message-ID
<1223751859-3540-1-git-send-email-mlevedahl@gmail.com>
In-Reply-To
<1223751280-2104-1-git-send-email-mlevedahl@gmail.com>

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 fores 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>
---
Resend as I mangled Shawn's email address.
 Documentation/config.txt |    4 +++-
 compat/cygwin.c          |   10 +++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 7161597..a3a9495 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -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
diff --git a/compat/cygwin.c b/compat/cygwin.c
index 423ff20..54028b3 100644
--- a/compat/cygwin.c
+++ b/compat/cygwin.c
@@ -91,13 +91,21 @@ 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 true, we *must* use the Cygwin posix stat as
+ * the Windows stat fuctions do not determine posix filemode.
  */
 static int native_stat = 1;
+static int core_filemode = 0;
 
 static int git_cygwin_config(const char *var, const char *value, void *cb)
 {
+	if (!strcmp(var, "core.filemode")) {
+			core_filemode = git_config_bool(var, value);
+			native_stat &= !core_filemode;
+	}
 	if (!strcmp(var, "core.ignorecygwinfstricks"))
-		native_stat = git_config_bool(var, value);
+		native_stat = git_config_bool(var, value) &&
+			!core_filemode;
 	return 0;
 }
 
-- 
1.6.0.2.535.g47d45.dirty
Previous: Mark LevedahlNext: Junio C Hamano
Message 2 of 11 in “compat/cygwin.c - Use cygwin's stat if core.filemode == true”
  1. compat/cygwin.c - Use cygwin's stat if core.filemode == trueMark Levedahl, Oct 11, 2008
  2. compat/cygwin.c - Use cygwin's stat if core.filemode == trueMark Levedahl, Oct 11, 2008
  3. Junio C HamanoOct 11, 2008
  4. compat/cygwin.c - Use cygwin's stat if core.filemode == trueMark Levedahl, Oct 11, 2008
  5. Dmitry PotapovOct 12, 2008
  6. compat/cygwin.c - Use cygwin's stat if core.filemode == trueMark Levedahl, Oct 12, 2008
  7. Junio C HamanoOct 12, 2008
  8. Mark LevedahlOct 12, 2008
  9. Junio C HamanoOct 12, 2008
  10. Mark LevedahlOct 13, 2008
  11. compat/cygwin.c - Use cygwin's stat if core.filemode == trueMark Levedahl, Oct 13, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.