<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/compat/winansi.c, branch gitk-resize-error</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=gitk-resize-error</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=gitk-resize-error'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2022-01-09T18:34:53Z</updated>
<entry>
<title>lazyload: use correct calling conventions</title>
<updated>2022-01-09T18:34:53Z</updated>
<author>
<name>Matthias Aßhauer</name>
<email>mha1993@live.de</email>
</author>
<published>2022-01-08T16:02:30Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=4a9b204920152c668228a9d43a63be39b0c32f45'/>
<id>urn:sha1:4a9b204920152c668228a9d43a63be39b0c32f45</id>
<content type='text'>
Christoph Reiter reported on the Git for Windows issue tracker[1], that
mingw_strftime() imports strftime() from ucrtbase.dll with the wrong
calling convention. It should be __cdecl instead of WINAPI, which we
always use in DECLARE_PROC_ADDR().

The MSYS2 project encountered cmake sefaults on x86 Windows caused by
the same issue in the cmake source. [2] There are no known git crashes
that where caused by this, yet, but we should try to prevent them.

We import two other non-WINAPI functions via DECLARE_PROC_ADDR(), too.

* NtSetSystemInformation() (NTAPI)
* GetUserNameExW()         (SEC_ENTRY)

NTAPI, SEC_ENTRY and WINAPI are all ususally defined as __stdcall,
but there are circumstances where they're defined differently.

Teach DECLARE_PROC_ADDR() about calling conventions and be explicit
about when we want to use which calling convention.

Import winnt.h for the definition of NTAPI and sspi.h for SEC_ENTRY
near their respective only users.

[1] https://github.com/git-for-windows/git/issues/3560
[2] https://github.com/msys2/MINGW-packages/issues/10152

Reported-By: Christoph Reiter &lt;reiter.christoph@gmail.com&gt;
Signed-off-by: Matthias Aßhauer &lt;mha1993@live.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mingw: work around incorrect standard handles</title>
<updated>2019-11-23T02:17:01Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-11-22T14:41:03Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=c5a03b1e29c69f3f06c8fabd92493edb73469176'/>
<id>urn:sha1:c5a03b1e29c69f3f06c8fabd92493edb73469176</id>
<content type='text'>
For some reason, when being called via TortoiseGit the standard handles,
or at least what is returned by _get_osfhandle(0) for standard input,
can take on the value (HANDLE)-2 (which is not a legal value, according
to the documentation).

Even if this value is not documented anywhere, CreateProcess() seems to
work fine without complaints if hStdInput set to this value.

In contrast, the upcoming code to restrict which file handles get
inherited by spawned processes would result in `ERROR_INVALID_PARAMETER`
when including such handle values in the list.

To help this, special-case the value (HANDLE)-2 returned by
_get_osfhandle() and replace it with INVALID_HANDLE_VALUE, which will
hopefully let the handle inheritance restriction work even when called
from TortoiseGit.

This fixes https://github.com/git-for-windows/git/issues/1481

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>winansi: use FLEX_ARRAY to avoid compiler warning</title>
<updated>2019-10-06T00:07:44Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-10-04T15:09:27Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=41616ef6182271178c63e1caf0d21f12bea2d41e'/>
<id>urn:sha1:41616ef6182271178c63e1caf0d21f12bea2d41e</id>
<content type='text'>
MSVC would complain thusly:

    C4200: nonstandard extension used: zero-sized array in struct/union

Let's just use the `FLEX_ARRAY` constant that we introduced for exactly
this type of scenario.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'js/mingw-use-utf8'</title>
<updated>2019-07-11T22:16:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-07-11T22:16:49Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=0a2ff7c6b5ec5e4301a9cfb3c0dd26590d70ad7a'/>
<id>urn:sha1:0a2ff7c6b5ec5e4301a9cfb3c0dd26590d70ad7a</id>
<content type='text'>
Windows update.

* js/mingw-use-utf8:
  mingw: fix possible buffer overrun when calling `GetUserNameW()`
  mingw: use Unicode functions explicitly
  mingw: get pw_name in UTF-8 format
</content>
</entry>
<entry>
<title>Merge branch 'jh/msvc'</title>
<updated>2019-07-09T22:25:45Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-07-09T22:25:45Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=88b10757593ab47354a3c9d191d7c03d584a40cf'/>
<id>urn:sha1:88b10757593ab47354a3c9d191d7c03d584a40cf</id>
<content type='text'>
Support to build with MSVC has been updated.

* jh/msvc:
  msvc: ignore .dll and incremental compile output
  msvc: avoid debug assertion windows in Debug Mode
  msvc: do not pretend to support all signals
  msvc: add pragmas for common warnings
  msvc: add a compile-time flag to allow detailed heap debugging
  msvc: support building Git using MS Visual C++
  msvc: update Makefile to allow for spaces in the compiler path
  msvc: fix detect_msys_tty()
  msvc: define ftello()
  msvc: do not re-declare the timespec struct
  msvc: mark a variable as non-const
  msvc: define O_ACCMODE
  msvc: include sigset_t definition
  msvc: fix dependencies of compat/msvc.c
  mingw: replace mingw_startup() hack
  obstack: fix compiler warning
  cache-tree/blame: avoid reusing the DEBUG constant
  t0001 (mingw): do not expect a specific order of stdout/stderr
  Mark .bat files as requiring CR/LF endings
  mingw: fix a typo in the msysGit-specific section
</content>
</entry>
<entry>
<title>mingw: use Unicode functions explicitly</title>
<updated>2019-06-27T19:56:15Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-06-27T09:37:19Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=94238859b9809afc806919cb7022a45cdc8e6748'/>
<id>urn:sha1:94238859b9809afc806919cb7022a45cdc8e6748</id>
<content type='text'>
Many Win32 API functions actually exist in two variants: one with
the `A` suffix that takes ANSI parameters (`char *` or `const char *`)
and one with the `W` suffix that takes Unicode parameters (`wchar_t *`
or `const wchar_t *`).

The ANSI variant assumes that the strings are encoded according to
whatever is the current locale. This is not what Git wants to use on
Windows: we assume that `char *` variables point to strings encoded in
UTF-8.

There is a pseudo UTF-8 locale on Windows, but it does not work
as one might expect. In addition, if we overrode the user's locale, that
would modify the behavior of programs spawned by Git (such as editors,
difftools, etc), therefore we cannot use that pseudo locale.

Further, it is actually highly encouraged to use the Unicode versions
instead of the ANSI versions, so let's do precisely that.

Note: when calling the Win32 API functions _without_ any suffix, it
depends whether the `UNICODE` constant is defined before the relevant
headers are #include'd. Without that constant, the ANSI variants are
used. Let's be explicit and avoid that ambiguity.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>msvc: fix detect_msys_tty()</title>
<updated>2019-06-20T21:03:05Z</updated>
<author>
<name>Jeff Hostetler</name>
<email>jeffhost@microsoft.com</email>
</author>
<published>2019-06-19T21:06:05Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=5f3ff7808132a1a4edae9628b0861bd18db9a4d0'/>
<id>urn:sha1:5f3ff7808132a1a4edae9628b0861bd18db9a4d0</id>
<content type='text'>
The ntstatus.h header is only available in MINGW.

Signed-off-by: Jeff Hostetler &lt;jeffhost@microsoft.com&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>winansi: simplify loading the GetCurrentConsoleFontEx() function</title>
<updated>2019-06-13T16:34:16Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2019-06-13T11:49:46Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=4fa42df972dc40fa3b50195ace838f2269da977a'/>
<id>urn:sha1:4fa42df972dc40fa3b50195ace838f2269da977a</id>
<content type='text'>
We introduced helper macros to simplify loading functions dynamically.
Might just as well use them.

This also side-steps a compiler warning when building with GCC v8.x: it
would complain about casting between incompatible function pointers.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mingw: fix isatty() after dup2()</title>
<updated>2018-10-31T03:48:59Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2018-10-30T18:44:40Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=ff8978d533207f472b183223d88786b1053f1989'/>
<id>urn:sha1:ff8978d533207f472b183223d88786b1053f1989</id>
<content type='text'>
Since a9b8a09c3c30 (mingw: replace isatty() hack, 2016-12-22), we handle
isatty() by special-casing the stdin/stdout/stderr file descriptors,
caching the return value. However, we missed the case where dup2()
overrides the respective file descriptor.

That poses a problem e.g. where the `show` builtin asks for a pager very
early, the `setup_pager()` function sets the pager depending on the
return value of `isatty()` and then redirects stdout. Subsequently,
`cmd_log_init_finish()` calls `setup_pager()` *again*. What should
happen now is that `isatty()` reports that stdout is *not* a TTY and
consequently stdout should be left alone.

Let's override dup2() to handle this appropriately.

This fixes https://github.com/git-for-windows/git/issues/1077

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>winansi: avoid buffer overrun</title>
<updated>2017-05-08T03:18:19Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2017-05-04T13:55:34Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=b6b066adf9e1e970a6d8295db630ab1e1f3bc71c'/>
<id>urn:sha1:b6b066adf9e1e970a6d8295db630ab1e1f3bc71c</id>
<content type='text'>
When we could not convert the UTF-8 sequence into Unicode for writing to
the Console, we should not try to write an insanely-long sequence of
invalid wide characters (mistaking the negative return value for an
unsigned length).

Reported by Coverity.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
