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

Re: [Outreachy][PATCH 2/2] Port helper/test-date.c to unit-tests/t-date.c

From
Junio C Hamano <gitster@pobox.com>
Date
May 28, 2024, 16:41 UTC
Message-ID
<xmqq7cfd7ut0.fsf@gitster.g>
In-Reply-To
<ZlXaDWy0lQA1FM7d@tanuki>
Patrick Steinhardt <ps@pks.im> writes:
Show 12 quoted lines
> As I was debugging other Windows-specific issues in a VM already, Chris
> asked me to also have a look at this issue. And indeed, most of the
> tests fail deterministically. I also found a fix:
> ...
>     -	setenv("TZ", zone, 1);
>     +	_putenv_s("TZ", zone);
>         tzset();
>      }
>
> I have no idea why that works though, and the fix is of course not
> portable. But with this change, the timezones do get picked up by
> `tzset()` and related date functions as expected.

The header compat/mingw.h already talks about implementing its own replacement by making gitsetenv() call mingw_putenv().

gitsetenv() emulates setenv() in terms of putenv(), and on Windows mingw_putenv() is what implements putenv(), so the difference you are observing is coming from the difference between mingw_putenv() and _putenv_s(), I would guess. As the former is isolated within compat/mingw.c, it would not involve any additional portability issues to redo the former in terms of the latter, I would imagine.

> I'm quite dumb when it comes to the Windows API, so I don't have much of
> a clue why this works. The documentation also didn't point out anything
> obvious. Dscho, do you happen to have an explanation for this?
Thanks.
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 6 of 10 in “date: refactor 64 bit prereq code into reusable functions”
  1. Achu LumaFeb 5, 2024
  2. [Outreachy][PATCH 2/2] Port helper/test-date.c to unit-tests/t-date.cAchu Luma, Feb 5, 2024
  3. Ghanshyam ThakkarMar 28, 2024
  4. Junio C HamanoMar 28, 2024
  5. Patrick SteinhardtMay 28, 2024
  6. Junio C HamanoMay 28, 2024
  7. Patrick SteinhardtMay 29, 2024
  8. Johannes SchindelinJun 27, 2024
  9. rsbecker@nexbridge.comFeb 5, 2024
  10. Christian CouderFeb 6, 2024

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.