diff options
author | Haaris Mehmood <hsed@unimetic.com> | 2017-11-18 02:27:27 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-18 12:31:29 +0900 |
commit | 5f9674243d0341519e5031681c941b0e1ad7a9e3 (patch) | |
tree | 26e797cc693541bcd3eaaa83c610894bb2982ae5 /t/helper | |
parent | 89ea799ffcc5c8a0547d3c9075eb979256ee95b8 (diff) | |
download | git-5f9674243d0341519e5031681c941b0e1ad7a9e3.tar.gz git-5f9674243d0341519e5031681c941b0e1ad7a9e3.tar.xz |
config: add --expiry-date
Add --expiry-date as a data-type for config files when
'git config --get' is used. This will return any relative
or fixed dates from config files as timestamps.
This is useful for scripts (e.g. gc.reflogexpire) that work
with timestamps so that '2.weeks' can be converted to a format
acceptable by those scripts/functions.
Following the convention of git_config_pathname(), move
the helper function required for this feature from
builtin/reflog.c to builtin/config.c where other similar
functions exist (e.g. for --bool or --path), and match
the order of parameters with other functions (i.e. output
pointer as first parameter).
Signed-off-by: Haaris Mehmood <hsed@unimetic.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper')
-rw-r--r-- | t/helper/test-date.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/t/helper/test-date.c b/t/helper/test-date.c index f414a3ac6..ac8368797 100644 --- a/t/helper/test-date.c +++ b/t/helper/test-date.c @@ -5,6 +5,7 @@ static const char *usage_msg = "\n" " test-date show:<format> [time_t]...\n" " test-date parse [date]...\n" " test-date approxidate [date]...\n" +" test-date timestamp [date]...\n" " test-date is64bit\n" " test-date time_t-is64bit\n"; @@ -71,6 +72,15 @@ static void parse_approxidate(const char **argv, struct timeval *now) } } +static void parse_approx_timestamp(const char **argv, struct timeval *now) +{ + for (; *argv; argv++) { + timestamp_t t; + t = approxidate_relative(*argv, now); + printf("%s -> %"PRItime"\n", *argv, t); + } +} + int cmd_main(int argc, const char **argv) { struct timeval now; @@ -95,6 +105,8 @@ int cmd_main(int argc, const char **argv) parse_dates(argv+1, &now); else if (!strcmp(*argv, "approxidate")) parse_approxidate(argv+1, &now); + else if (!strcmp(*argv, "timestamp")) + parse_approx_timestamp(argv+1, &now); else if (!strcmp(*argv, "is64bit")) return sizeof(timestamp_t) == 8 ? 0 : 1; else if (!strcmp(*argv, "time_t-is64bit")) |