I can confirm this fault. As git bash shells seem to operate fine,
perhaps this is better just done in the git.cmd and git-cmd.cmd launch
scripts. For git-bash we seem to have TERM set to cygwin although as
setting TERM=msys works that would seem to make more sense. For
colours, we just require TERM to not be 'dumb'. I guess anything else
is down to 'less'.
I am re-Cc:ing Pat (dunno whether there are others I am missing); this is
a little tedious, please respect the "Please reply-to-all" in the mail
signature in the future.
On Wed, 11 Apr 2012, Tale wrote:
> On 10 apr, 19:03, Pat Thoyts <pattho...@gmail.com> wrote:
> > I can confirm this fault. As git bash shells seem to operate fine,
> > perhaps this is better just done in the git.cmd and git-cmd.cmd launch
> > scripts. For git-bash we seem to have TERM set to cygwin although as
> > setting TERM=msys works that would seem to make more sense. For
> > colours, we just require TERM to not be 'dumb'. I guess anything else
> > is down to 'less'.- Tekst uit oorspronkelijk bericht niet weergeven -
>
> Agreed! This patch instead then?
I like it! Pat, if you agree, can you please apply and push?
Thanks!
Dscho
Done. I found in testing that we don't need to do anything to
git-cmd.cmd as that just opens a shell that lets you call git.cmd.
Redone the commit message too
> On 11 April 2012 16:37, Johannes Schindelin <Johannes.
> Schin...@gmx.de> wrote:
> > Hi,
> >> Agreed! This patch instead then?
> >
> > I like it! Pat, if you agree, can you please apply and push?
>
> Done. I found in testing that we don't need to do anything to
> git-cmd.cmd as that just opens a shell that lets you call git.cmd.
> Redone the commit message too
>
I realize I'm a bit late to the discussion, anyways...
If we set TERM in git.cmd (assuming that git.exe is always called via
git.cmd), we probably should also remove the special TERM handling in
mingw.c::mingw_startup(). There's no point in having similar workarounds
in two places.
However, I think it would be better to tackle the root of the problem.
Git's auto-color mode is enabled under these circumstances (see
color.c::check_auto_color):
1) the user has explicitly set color.ui = auto (actually: != always|never)
2) stdout is a tty
3) TERM is set
4) TERM is not "dumb"
In the presence of (1) and (4), I think that (3) can safely be removed for
systems that usually don't have a TERM variable (probably Mac OS X, too?).
Git isn't interested in a proper TERM setting at all, so why require it?
Something like this:
------8<-------
diff --git a/color.c b/color.c
index e8e2681..c92d7cc 100644
--- a/color.c
+++ b/color.c
@@ -186,7 +186,7 @@ static int check_auto_color(void)
color_stdout_is_tty = isatty(1);
if (color_stdout_is_tty || (pager_in_use() && pager_use_color)) {
char *term = getenv("TERM");
- if (term && strcmp(term, "dumb"))
+ if (!term || strcmp(term, "dumb"))
return 1;
}
return 0;
diff --git a/compat/mingw.c b/compat/mingw.c
index e6f331a..4a58866 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -2123,10 +2123,6 @@ void mingw_startup()
setenv("TMPDIR", tmp, 1);
}
- /* simulate TERM to enable auto-color (see color.c) */
- if (!getenv("TERM"))
- setenv("TERM", "winansi", 1);
-
/* initialize critical section for waitpid pinfo_t list */
InitializeCriticalSection(&pinfo_cs);
-----8<-----
Actually, there are two more places that check TERM in pretty much the
same way, so to make it pretty I'd add a is_terminal_dumb function that
could even do different things on *nix/Mac/Windows.
Btw.: Less works without a TERM setting because MSYS.dll sets TERM=cygwin
in it's startup code, and it doesn't work with TERM=winansi because
there's no such entry in etc/termcap.
Bye,
Karsten