mbox series

[v2,0/2] Date test code clean-up

Message ID 20190912041102.16266-1-ischis2@cox.net (mailing list archive)
Headers show
Series Date test code clean-up | expand

Message

Stephen P. Smith Sept. 12, 2019, 4:11 a.m. UTC
As part of a previous patch submission[1], a cleanup patch was
suggested to remove a now unnecessary passing of a date environment
variable to the production code.

While the two patches in the set could easily be submitted as a single
patch, I split the removal of the getenv() call into a second
patch. I did that to make the comment about the initialization of `x`
more localized to the change.

[1] https://public-inbox.org/git/xmqq5zuge2y7.fsf@gitster-ct.c.googlers.com

Range Diff:
1:  f4170ad553 ! 1:  e2b8322d58 Quit passing 'now' to date code
    @@ Metadata
      ## Commit message ##
         Quit passing 'now' to date code
     
    -    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.
    +    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().
     
    -    This patch removes the unneeded `now` parameter.
    +    Therefore, 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().
     
      ## cache.h ##
     @@ cache.h: struct date_mode {
2:  3c7c4f1f55 ! 2:  18ec5b3b3d test_date.c: Remove reference to GIT_TEST_DATE_NOW
    @@ Commit message
         test_date.c: Remove reference to GIT_TEST_DATE_NOW
     
         Remove the reference to the GIT_TEST_DATE_NOW which is done in date.c.
    -    The intialization of variable x with the value from GIT_TEST_DATE_NOW
    -    is unneeded since x is initalized by skip_prefix().
    +    We can't get rid of the "x" variable, since it serves as a generic
    +    scratch variable for parsing later in the function.
     
      ## t/helper/test-date.c ##
     @@ t/helper/test-date.c: static void getnanos(const char **argv)


Stephen P. Smith (2):
  Quit passing 'now' to date code
  test_date.c: Remove reference to GIT_TEST_DATE_NOW

 cache.h              |  5 ++---
 date.c               | 27 +++++++++++++--------------
 t/helper/test-date.c | 27 +++++++++------------------
 3 files changed, 24 insertions(+), 35 deletions(-)

Comments

Jeff King Sept. 13, 2019, 5:08 a.m. UTC | #1
On Wed, Sep 11, 2019 at 09:11:00PM -0700, Stephen P. Smith wrote:

> Range Diff:
> 1:  f4170ad553 ! 1:  e2b8322d58 Quit passing 'now' to date code
> [...]

Thanks, this version addresses all of my concerns from v1 (and overall
looks good).

-Peff
Junio C Hamano Sept. 13, 2019, 5:25 p.m. UTC | #2
Jeff King <peff@peff.net> writes:

> On Wed, Sep 11, 2019 at 09:11:00PM -0700, Stephen P. Smith wrote:
>
>> Range Diff:
>> 1:  f4170ad553 ! 1:  e2b8322d58 Quit passing 'now' to date code
>> [...]
>
> Thanks, this version addresses all of my concerns from v1 (and overall
> looks good).

Yup, the result of applying these look good.

Thanks, both.