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

Re: [PATCH 1/2] Quit passing 'now' to date code

From
Jeff King <peff@peff.net>
Date
Sep 9, 2019, 17:28 UTC
Message-ID
<20190909172832.GB30470@sigill.intra.peff.net>
In-Reply-To
<20190909014711.3894-2-ischis2@cox.net>
On Sun, Sep 08, 2019 at 06:47:10PM -0700, Stephen P. Smith wrote:
> As part of a previous patch set, the get_time() function was added to
> date.c eliminating the need to pass a `now` parameter from the test
> code.

I'm glad to see this cleanup. I think it is worth explaining a bit more, though, why this hunk in particular:

Show 14 quoted lines
> @@ -103,22 +103,14 @@ static void getnanos(const char **argv)
>  
>  int cmd__date(int argc, const char **argv)
>  {
> -	struct timeval now;
>  	const char *x;
> -
>  	x = getenv("GIT_TEST_DATE_NOW");
> -	if (x) {
> -		now.tv_sec = atoi(x);
> -		now.tv_usec = 0;
> -	}
> -	else
> -		gettimeofday(&now, NULL);

...is doing the right thing, since it was the site that actually used the parameters that are being deleted. Maybe something like:

  Commit b841d4ff43 (Add `human` format to test-tool, 2019-01-28) added
  a get_time() function which allows $GIT_TEST_DATE_NOW in the
  environment to override the current time. So we no longer need to
  interpret that variable in cmd__date().
  Likewise, we can stop passing the "now" parameter down through the
  date functions, since nobody uses them. Note that we do need to make
  sure all of the previous callers that took a "now" parameter are
  correctly using get_time().
which I think explains all of the hunks.
-Peff
Previous: Stephen P. SmithNext: Junio C Hamano
Message 6 of 12 in “Date test code clean-up”
  1. 0/2 Date test code clean-upStephen P. Smith, Sep 9, 2019
  2. 2/2 test_date.c: Remove reference to GIT_TEST_DATE_NOWStephen P. Smith, Sep 9, 2019
  3. Jeff KingSep 9, 2019
  4. Junio C HamanoSep 9, 2019
  5. 1/2 Quit passing 'now' to date codeStephen P. Smith, Sep 9, 2019
  6. Jeff KingSep 9, 2019
  7. Junio C HamanoSep 9, 2019
  8. 0/2 Date test code clean-upStephen P. Smith, Sep 12, 2019
  9. 2/2 test_date.c: Remove reference to GIT_TEST_DATE_NOWStephen P. Smith, Sep 12, 2019
  10. 1/2 Quit passing 'now' to date codeStephen P. Smith, Sep 12, 2019
  11. Jeff KingSep 13, 2019
  12. Junio C HamanoSep 13, 2019

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.