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

[PATCH] mingw: work around stat-limitation

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Feb 23, 2012, 20:25 UTC
Message-ID
<1330028744-5280-1-git-send-email-kusmabite@gmail.com>

Our stat implementation for Windows always sets st_ino to 0. This means that checking if isatty(0) and comparing the reported inodes of stdout and stdin is not sufficient to detect that both are pointing to the same TTY.

Luckily, there's only one console on Windows, so adding a check for isatty(1) should do the trick. For platforms where inodes are reported correctly, this should still be correct.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
Here's a proper patch for this glitch.
 builtin/merge.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index ed0f959..bef01e3 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1130,6 +1130,7 @@ static int default_edit_option(void)
 	return (!fstat(0, &st_stdin) &&
 		!fstat(1, &st_stdout) &&
 		isatty(0) &&
+		isatty(1) &&
 		st_stdin.st_dev == st_stdout.st_dev &&
 		st_stdin.st_ino == st_stdout.st_ino &&
 		st_stdin.st_mode == st_stdout.st_mode);
-- 
1.7.9
Next: Johannes Schindelin
Message 1 of 4 in “mingw: work around stat-limitation”
  1. mingw: work around stat-limitationErik Faye-Lund, Feb 23, 2012
  2. Johannes SchindelinFeb 23, 2012
  3. Erik Faye-LundFeb 23, 2012
  4. Johannes SchindelinFeb 23, 2012

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.