Changed the binary and test to rename TEST_DATE_NOW environment variable. Changed the 'human' test to test_i18ncmp. Updates for the relative date format will be done in a follow-on patch. Range-diff relative to v3: 1: ee75d9002d = 1: ee75d9002d Add 'human' date format 2: 722c3319cd = 2: 722c3319cd Replace the proposed 'auto' mode with 'auto:' 3: 67cb73edb4 = 3: 67cb73edb4 Add 'human' date format documentation 4: 1562e7c713 ! 4: a3f6f820b2 Add `human` format to test-tool @@ -2,15 +2,19 @@ Add `human` format to test-tool - Add the human format support to the test tool so that TEST_DATE_NOW - can be used to specify the current time. + Add the human format support to the test tool so that + GIT_TEST_DATE_NOW can be used to specify the current time. The get_time() helper function was created and and checks the - TEST_DATE_NOW environment variable. If TEST_DATE_NOW is set, then - that date is used instead of the date returned by by gettimeofday(). + GIT_TEST_DATE_NOW environment variable. If GIT_TEST_DATE_NOW is set, + then that date is used instead of the date returned by by + gettimeofday(). All calls to gettimeofday() were replaced by calls to get_time(). + Renamed occurances of TEST_DATE_NOW to GIT_TEST_DATE_NOW since the + variable is now used in the get binary and not just in the test-tool. + diff --git a/cache.h b/cache.h --- a/cache.h +++ b/cache.h @@ -35,7 +39,7 @@ +{ + const char *x; + -+ x = getenv("TEST_DATE_NOW"); ++ x = getenv("GIT_TEST_DATE_NOW"); + if (x) { + now->tv_sec = atoi(x); + now->tv_usec = 0; @@ -110,6 +114,15 @@ static void show_dates(const char **argv, const char *format) { struct date_mode mode; +@@ + struct timeval now; + const char *x; + +- x = getenv("TEST_DATE_NOW"); ++ x = getenv("GIT_TEST_DATE_NOW"); + if (x) { + now.tv_sec = atoi(x); + now.tv_usec = 0; @@ usage(usage_msg); if (!strcmp(*argv, "relative")) @@ -119,3 +132,20 @@ else if (skip_prefix(*argv, "show:", &x)) show_dates(argv+1, x); else if (!strcmp(*argv, "parse")) + + diff --git a/t/t0006-date.sh b/t/t0006-date.sh + --- a/t/t0006-date.sh + +++ b/t/t0006-date.sh +@@ + . ./test-lib.sh + + # arbitrary reference time: 2009-08-30 19:20:00 +-TEST_DATE_NOW=1251660000; export TEST_DATE_NOW ++GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW + + check_relative() { +- t=$(($TEST_DATE_NOW - $1)) ++ t=$(($GIT_TEST_DATE_NOW - $1)) + echo "$t -> $2" >expect + test_expect_${3:-success} "relative date ($2)" " + test-tool date relative $t >actual && 5: 5e6b5705fd ! 5: 87d3a81e8a Add `human` date format tests. @@ -19,11 +19,11 @@ check_approxidate '2009-12-01' '2009-12-01 19:20:00' +check_date_format_human() { -+ t=$(($TEST_DATE_NOW - $1)) ++ t=$(($GIT_TEST_DATE_NOW - $1)) + echo "$t -> $2" >expect + test_expect_success "human date $t" ' -+ test-tool date human $t >actual && -+ test_cmp expect actual ++ test-tool date human $t >actual && ++ test_i18ncmp expect actual +' +} + Linus Torvalds (1): Add 'human' date format Stephen P. Smith (4): Replace the proposed 'auto' mode with 'auto:' Add 'human' date format documentation Add `human` format to test-tool Add `human` date format tests. Documentation/git-log.txt | 4 + Documentation/rev-list-options.txt | 7 ++ builtin/blame.c | 4 + cache.h | 3 + date.c | 148 ++++++++++++++++++++++++----- t/helper/test-date.c | 13 ++- t/t0006-date.sh | 22 ++++- 7 files changed, 176 insertions(+), 25 deletions(-) -- 2.20.1.2.gb21ebb671b