git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: git@vger.kernel.org, Jeff Hostetler <jeffhost@microsoft.com>,
	Pranit Bauva <pranit.bauva@gmail.com>,
	Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCH 2/2] mingw: replace isatty() hack
Date: Wed, 21 Dec 2016 10:45:22 -0800	[thread overview]
Message-ID: <xmqqpokli0jh.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <18174f0a7fbb4a0ccd8ca8380e00161826166a32.1482342791.git.johannes.schindelin@gmx.de> (Johannes Schindelin's message of "Wed, 21 Dec 2016 18:53:43 +0100 (CET)")

Johannes Schindelin <johannes.schindelin@gmx.de> writes:

> From: Jeff Hostetler <jeffhost@microsoft.com>
>
> For over a year, Git for Windows has carried a patch that detects the
> MSYS2 pseudo ttys used by Git for Windows' default Git Bash (i.e. a
> terminal that is not backed by a Win32 Console).
>
> This patch accesses internals that of a previous MSVC runtime that is no
> longer valid in newer versions, therefore we needed a replacement for
> that hack in order to be able to compile Git using recent Microsoft
> Visual C++.

Sorry, but I cannot parse the early part of the first sentence of
the second paragraph before the comma; I am especially having
trouble around the first "that".

> This patch back-ports that patch and makes even the MINGW (i.e.
> GCC-compiled) Git use it.
>
> As a side effect (which was the reason for the back-port), this patch
> also fixes the previous misguided attempt to intercept isatty() so that
> it handles character devices (such as /dev/null) as Git expects it.

I had to read the above three times to understand which patches
three instances of "This patch" and one instance of "that patch"
refer to.  I wish it were easier to read, but I think I got them all
right [*1*] after re-reading, and the story made sense to me.

> +static int fd_is_interactive[3] = { 0, 0, 0 };
> +#define FD_CONSOLE 0x1
> +#define FD_SWAPPED 0x2
> +#define FD_MSYS    0x4
>  
>  /*
>   ANSI codes used by git: m, K
> @@ -105,6 +108,9 @@ static int is_console(int fd)
>  	} else if (!GetConsoleScreenBufferInfo(hcon, &sbi))
>  		return 0;
>  
> +	if (fd >=0 && fd <= 2)

Style: if (fd >= 0 && fd <= 2)

> +/* Wrapper for isatty().  Most calls in the main git code

Style: /*
	* multi-line comment block begins with slash-asterisk
        * and ends with asterisk-slash without anything else on
	* the line.
	*/

> + * call isatty(1 or 2) to see if the instance is interactive
> + * and should: be colored, show progress, paginate output.
> + * We lie and give results for what the descriptor WAS at
> + * startup (and ignore any pipe redirection we internally
> + * do).
> + */
> +#undef isatty
>  int winansi_isatty(int fd)
>  {
> +	if (fd >=0 && fd <= 2)

Style: if (fd >= 0 && fd <= 2)

> +		return fd_is_interactive[fd] != 0;
> +	return isatty(fd);
>  }

Thanks.


[Footnote]

*1* What I thought I understood in my own words:

    Git for Windows has carried a patch that depended on internals
    of MSVC runtime, but it does not work correctly with recent MSVC
    runtime.  A replacement was written originally for compiling
    with VC++.  The patch in this message is a backport of that
    replacement, and it also fixes the previous attempt to make
    isatty() work.


  reply	other threads:[~2016-12-21 18:45 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-21 17:53 [PATCH 0/2] Really fix the isatty() problem on Windows Johannes Schindelin
2016-12-21 17:53 ` [PATCH 1/2] mingw: adjust is_console() to work with stdin Johannes Schindelin
2016-12-21 17:53 ` [PATCH 2/2] mingw: replace isatty() hack Johannes Schindelin
2016-12-21 18:45   ` Junio C Hamano [this message]
2016-12-21 21:15 ` [PATCH 0/2] Really fix the isatty() problem on Windows Johannes Sixt
2016-12-21 21:21   ` Junio C Hamano
2016-12-22 18:48   ` Johannes Sixt
2016-12-22 21:33     ` Johannes Schindelin
2016-12-22 17:08 ` [PATCH v2 0/3] " Johannes Schindelin
2016-12-22 17:08   ` [PATCH v2 1/3] mingw: adjust is_console() to work with stdin Johannes Schindelin
2016-12-22 23:04     ` Beat Bolli
2016-12-22 23:18       ` Junio C Hamano
2016-12-23  9:30       ` Johannes Schindelin
2016-12-23 12:51         ` Beat Bolli
2016-12-22 17:09   ` [PATCH v2 2/3] mingw: fix colourization on Cygwin pseudo terminals Johannes Schindelin
2016-12-22 17:09   ` [PATCH v2 3/3] mingw: replace isatty() hack Johannes Schindelin
2016-12-22 20:26     ` Johannes Sixt
2016-12-22 21:37       ` Johannes Schindelin
2016-12-22 22:28         ` Johannes Sixt
2016-12-22 23:18           ` Johannes Schindelin
2016-12-22 17:49   ` [PATCH v2 0/3] Really fix the isatty() problem on Windows Junio C Hamano
2016-12-22 17:59     ` Johannes Schindelin
2016-12-22 18:32       ` Junio C Hamano
2016-12-22 18:19     ` Junio C Hamano
2016-12-22 23:16   ` [PATCH v3 " Johannes Schindelin
2016-12-22 23:16     ` [PATCH v3 1/3] mingw: adjust is_console() to work with stdin Johannes Schindelin
2016-12-22 23:16     ` [PATCH v3 2/3] mingw: fix colourization on Cygwin pseudo terminals Johannes Schindelin
2016-12-22 23:16     ` [PATCH v3 3/3] mingw: replace isatty() hack Johannes Schindelin
2017-01-18 12:13       ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqpokli0jh.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=jeffhost@microsoft.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=pranit.bauva@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).